{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/2-150317-data-merge-log.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}17 Mar 2015, 13:28:21

{com}. 
. **** Load MID 4.01B data, downloaded from 

. **** http://www.correlatesofwar.org/data-sets/MIDs

. import delimited "1-Original-Data/MID-level/MIDB_4.01.csv"
{res}{err}file 1-Original-Data/MID-level/MIDB_4.01.csv not found
{txt}{search r(601):r(601);}

{com}. 
. ** Drop MIDs not involving the US

. keep if ccode==2
{err}ccode not found
{txt}{search r(111):r(111);}

{com}. 
. sort dispnum3 dispnum4 ccode
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. save "1-Original-Data/MIDB-US.dta", replace
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. 
. 
. **** Load MID 4.01A data

. clear

. import delimited "1-Original-Data/MID-level/MIDA_4.01.csv"
{res}{err}file 1-Original-Data/MID-level/MIDA_4.01.csv not found
{txt}{search r(601):r(601);}

{com}. sort dispnum3 dispnum4
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. save "1-Original-Data/MIDA.dta", replace
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. 
. 
. **** Merge MIDB and MIDA data

. clear

. use "1-Original-Data/MIDB-US.dta"
{err}{p 0 4 2}
file 1-Original-Data/MIDB-US.dta
not found
{p_end}
{txt}{search r(601):r(601);}

{com}. merge 1:1 dispnum3 dispnum4 using "1-Original-Data/MIDA.dta", gen(mergeid)
{res}{err}no variables defined
{txt}{search r(111):r(111);}

{com}. 
. keep if mergeid==3
{err}mergeid not found
{txt}{search r(111):r(111);}

{com}. drop mergeid
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. 
. ** Generating start and end dates

. gen StartDateUS = mdy(stmon, stday, styear) 
{err}styear not found
{txt}{search r(111):r(111);}

{com}. gen EndDateUS = mdy(endmon, endday, endyear)
{err}endyear not found
{txt}{search r(111):r(111);}

{com}. 
. ** If day is missing, replace day with 15th (an approximation)

. replace StartDateUS = mdy(stmon, 15, styear) if StartDateUS==.
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. replace EndDateUS = mdy(endmon, 15, endyear) if EndDateUS==.
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. 
. format StartDateUS EndDateUS %td 
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. order StartDateUS EndDateUS
{err}no variables defined
{txt}{search r(111):r(111);}

{com}. 
. gen LngthMIDUS = EndDateUS - StartDateUS + 1
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. 
. **** Assigning Outcome

. rename outcome outcomeMID
{res}{err}no variables defined
{txt}{search r(111):r(111);}

{com}. gen outcome = .

. 
. ** outcome = 1 if US has Victory or other side Yields

. replace outcome = 1 if sidea==1 & (outcomeMID==1 | outcomeMID==4)
{err}sidea not found
{txt}{search r(111):r(111);}

{com}. replace outcome = 1 if sidea==0 & (outcomeMID==2 | outcomeMID==3)
{err}sidea not found
{txt}{search r(111):r(111);}

{com}. 
. ** outcome = -1 if other has Victory or US Yields

. replace outcome = -1 if sidea==1 & (outcomeMID==2 | outcomeMID==3)
{err}sidea not found
{txt}{search r(111):r(111);}

{com}. replace outcome = -1 if sidea==0 & (outcomeMID==1 | outcomeMID==4)
{err}sidea not found
{txt}{search r(111):r(111);}

{com}. 
. ** outcome = 0 if other coding

. replace outcome = 0 if outcomeMID>4 | outcomeMID==. | outcomeMID < 0
{err}outcomeMID not found
{txt}{search r(111):r(111);}

{com}. 
. ** Indicator for whether the US used force in the MID

. gen ForceUS = 0

. replace ForceUS = 1 if hostlev >= 4      
{err}hostlev not found
{txt}{search r(111):r(111);}

{com}. 
. ** Ordering Variables: date, outcome variables, treatment, controls

. order StartDateUS EndDateUS outcome fatality LngthMIDUS ForceUS
{err}variable StartDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. 
. **** Generate President variables

. gen Pres1 = ""

. order Pres1 EndDateUS StartDateUS
{err}variable EndDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. sort StartDateUS dispnum3 dispnum4
{err}variable StartDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. ** Assign presidents to MIDs

. replace Pres1 = "Madison" if StartDateUS>=mdy(03, 04, 1809) & EndDateUS<mdy(03, 04, 1817)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Monroe"  if StartDateUS>=mdy(03, 04, 1817) & EndDateUS<mdy(03, 04, 1825)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "AdamsJQ" if StartDateUS>=mdy(03, 04, 1825) & EndDateUS<mdy(03, 04, 1829)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Jackson" if StartDateUS>=mdy(03, 04, 1829) & EndDateUS<mdy(03, 04, 1837)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Van_Buren" if StartDateUS>=mdy(03, 04, 1837) & EndDateUS<mdy(03, 04, 1841)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "HarrisonWH" if StartDateUS>=mdy(03, 04, 1841) & EndDateUS<mdy(04, 04, 1841)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Tyler" if StartDateUS>=mdy(04, 04, 1841) & EndDateUS<mdy(03, 04, 1845)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Polk" if StartDateUS>=mdy(03, 04, 1845) & EndDateUS<mdy(03, 04, 1849)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Taylor" if StartDateUS>=mdy(03, 04, 1849) & EndDateUS<mdy(03, 09, 1850)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Fillmore" if StartDateUS>=mdy(03, 09, 1850) & EndDateUS<mdy(03, 04, 1853)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Pierce" if StartDateUS>=mdy(03, 04, 1853) & EndDateUS<mdy(03, 04, 1857)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Buchanan" if StartDateUS>=mdy(03, 04, 1857) & EndDateUS<mdy(03, 04, 1861)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Lincoln" if StartDateUS>=mdy(03, 04, 1861) & EndDateUS<mdy(04, 15, 1865)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "JohnsonA" if StartDateUS>=mdy(04, 15, 1865) & EndDateUS<mdy(03, 04, 1869)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Grant" if StartDateUS>=mdy(03, 04, 1869) & EndDateUS<mdy(03, 04, 1877)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Hayes" if StartDateUS>=mdy(03, 04, 1877) & EndDateUS<mdy(03, 04, 1881)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Garfield" if StartDateUS>=mdy(03, 04, 1881) & EndDateUS<mdy(09, 19, 1881)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Arthur" if StartDateUS>=mdy(09, 19, 1881) & EndDateUS<mdy(03, 04, 1885)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Cleveland1" if StartDateUS>=mdy(03, 04, 1885) & EndDateUS<mdy(03, 04, 1889)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "HarrisonB" if StartDateUS>=mdy(03, 04, 1889) & EndDateUS<mdy(03, 04, 1893)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Cleveland2" if StartDateUS>=mdy(03, 04, 1893) & EndDateUS<mdy(03, 04, 1897)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "McKinley" if StartDateUS>=mdy(03, 04, 1897) & EndDateUS<mdy(09, 14, 1901)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "RooseveltT" if StartDateUS>=mdy(09, 14, 1901) & EndDateUS<mdy(03, 04, 1909)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Taft" if StartDateUS>=mdy(03, 04, 1909) & EndDateUS<mdy(03, 04, 1913)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Wilson" if StartDateUS>=mdy(03, 04, 1913) & EndDateUS<mdy(03, 04, 1921)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Harding" if StartDateUS>=mdy(03, 04, 1921) & EndDateUS<mdy(08, 02, 1923)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Coolidge" if StartDateUS>=mdy(08, 02, 1923) & EndDateUS<mdy(03, 04, 1929)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Hoover" if StartDateUS>=mdy(03, 04, 1929) & EndDateUS<mdy(03, 04, 1933)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "RooseveltFD" if StartDateUS>=mdy(03, 04, 1933) & EndDateUS<mdy(04, 12, 1945)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Truman" if StartDateUS>=mdy(04, 12, 1945) & EndDateUS<mdy(01, 20, 1953)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Eisenhower" if StartDateUS>=mdy(01, 20, 1953) & EndDateUS<mdy(01, 20, 1961)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Kennedy" if StartDateUS>=mdy(01, 20, 1961) & EndDateUS<mdy(11, 22, 1963)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "JohnsonLB" if StartDateUS>=mdy(11, 22, 1963) & EndDateUS<mdy(01, 20, 1969)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Nixon" if StartDateUS>=mdy(01, 20, 1969) & EndDateUS<mdy(08, 09, 1974)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Ford" if StartDateUS>=mdy(08, 09, 1974) & EndDateUS<mdy(01, 20, 1977)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Carter" if StartDateUS>=mdy(01, 20, 1977) & EndDateUS<mdy(01, 20, 1981)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Reagan" if StartDateUS>=mdy(01, 20, 1981) & EndDateUS<mdy(01, 20, 1989)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "BushGHW" if StartDateUS>=mdy(01, 20, 1989) & EndDateUS<mdy(01, 20, 1993)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Clinton" if StartDateUS>=mdy(01, 20, 1993) & EndDateUS<mdy(01, 20, 2001)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "BushGW" if StartDateUS>=mdy(01, 20, 2001) & EndDateUS<mdy(01, 20, 2009)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Obama" if StartDateUS>=mdy(01, 20, 2009) & EndDateUS<mdy(03, 13, 2015)
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. ** Note: Some MIDs spillover across Presidencies

. generate spillover = 0

. replace spillover = 1 if Pres1==""
{txt}(0 real changes made)

{com}. 
. ** Assigning spillover MIDs to first President to experience MID

. replace Pres1 = "Madison" if StartDateUS>=mdy(03, 04, 1809) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Monroe"  if StartDateUS>=mdy(03, 04, 1817) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "AdamsJQ" if StartDateUS>=mdy(03, 04, 1825) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Jackson" if StartDateUS>=mdy(03, 04, 1829) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Van_Buren" if StartDateUS>=mdy(03, 04, 1837) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "HarrisonWH" if StartDateUS>=mdy(03, 04, 1841) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Tyler" if StartDateUS>=mdy(04, 04, 1841) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Polk" if StartDateUS>=mdy(03, 04, 1845) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Taylor" if StartDateUS>=mdy(03, 04, 1849) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Fillmore" if StartDateUS>=mdy(03, 09, 1850) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Pierce" if StartDateUS>=mdy(03, 04, 1853) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Buchanan" if StartDateUS>=mdy(03, 04, 1857) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Lincoln" if StartDateUS>=mdy(03, 04, 1861) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "JohnsonA" if StartDateUS>=mdy(04, 15, 1865) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Grant" if StartDateUS>=mdy(03, 04, 1869) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Hayes" if StartDateUS>=mdy(03, 04, 1877) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Garfield" if StartDateUS>=mdy(03, 04, 1881) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Arthur" if StartDateUS>=mdy(09, 19, 1881) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Cleveland1" if StartDateUS>=mdy(03, 04, 1885) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "HarrisonB" if StartDateUS>=mdy(03, 04, 1897) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Cleveland2" if StartDateUS>=mdy(03, 04, 1893) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "McKinley" if StartDateUS>=mdy(03, 04, 1897) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "RooseveltT" if StartDateUS>=mdy(09, 14, 1901) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Taft" if StartDateUS>=mdy(03, 04, 1909) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Wilson" if StartDateUS>=mdy(03, 04, 1913) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Harding" if StartDateUS>=mdy(03, 04, 1921) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Coolidge" if StartDateUS>=mdy(08, 02, 1923) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Hoover" if StartDateUS>=mdy(03, 04, 1929) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "RooseveltFD" if StartDateUS>=mdy(03, 04, 1933) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Truman" if StartDateUS>=mdy(04, 12, 1945) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Eisenhower" if StartDateUS>=mdy(01, 20, 1953) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Kennedy" if StartDateUS>=mdy(01, 20, 1961) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "JohnsonLB" if StartDateUS>=mdy(11, 22, 1963) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Nixon" if StartDateUS>=mdy(01, 20, 1969) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Ford" if StartDateUS>=mdy(08, 09, 1974) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Carter" if StartDateUS>=mdy(01, 20, 1977) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Reagan" if StartDateUS>=mdy(01, 20, 1981) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "BushGHW" if StartDateUS>=mdy(01, 20, 1989) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Clinton" if StartDateUS>=mdy(01, 20, 1993) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "BushGW" if StartDateUS>=mdy(01, 20, 2001) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres1 = "Obama" if StartDateUS>=mdy(01, 20, 2009) & spillover==1
{err}StartDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. 
. ** Variable for the name of the President who was the first to inherit the MID

. gen Pres2 = ""

. replace Pres2 = "Obama" if spillover==1 & EndDateUS<mdy(01, 20, 2013)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "BushGW" if spillover==1 & EndDateUS<mdy(01, 20, 2009)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Clinton" if spillover==1 & EndDateUS<mdy(01, 20, 2001)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "BushGHW" if spillover==1 & EndDateUS<mdy(01, 20, 1993)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Reagan" if spillover==1 & EndDateUS<mdy(01, 20, 1989)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Carter" if spillover==1 & EndDateUS<mdy(01, 20, 1981)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Ford" if spillover==1 & EndDateUS<mdy(01, 20, 1977)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Nixon" if spillover==1 & EndDateUS<mdy(08, 09, 1974)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "JohnsonLB" if spillover==1 & EndDateUS<mdy(01, 20, 1969)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Kennedy" if spillover==1 & EndDateUS<mdy(11, 22, 1963)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Eisenhower" if spillover==1 & EndDateUS<mdy(01, 20, 1961)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Truman" if spillover==1 & EndDateUS<mdy(01, 20, 1953)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "RooseveltFD" if spillover==1 & EndDateUS<mdy(04, 12, 1945)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Hoover" if spillover==1 & EndDateUS<mdy(03, 04, 1933)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Coolidge" if spillover==1 & EndDateUS<mdy(03, 04, 1929)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Harding" if spillover==1 & EndDateUS<mdy(08, 02, 1923)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Wilson" if spillover==1 & EndDateUS<mdy(03, 04, 1921)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Taft" if spillover==1 & EndDateUS<mdy(03, 04, 1913)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "RooseveltT" if spillover==1 & EndDateUS<mdy(03, 04, 1909)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "McKinley" if spillover==1 & EndDateUS<mdy(09, 14, 1901)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Cleveland2" if spillover==1 & EndDateUS<mdy(03, 04, 1897)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "HarrisonB" if spillover==1 & EndDateUS<mdy(03, 04, 1893)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Cleveland1" if spillover==1 & EndDateUS<mdy(03, 04, 1889)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Arthur" if spillover==1 & EndDateUS<mdy(03, 04, 1885)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Garfield" if spillover==1 & EndDateUS<mdy(09, 19, 1881)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Hayes" if spillover==1 & EndDateUS<mdy(03, 04, 1881)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Grant" if spillover==1 & EndDateUS<mdy(03, 04, 1877)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "JohnsonA" if spillover==1 & EndDateUS<mdy(03, 04, 1869)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Lincoln" if spillover==1 & EndDateUS<mdy(04, 15, 1865)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Buchanan" if spillover==1& EndDateUS<mdy(03, 04, 1861)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Pierce" if spillover==1 & EndDateUS<mdy(03, 04, 1857)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Fillmore" if spillover==1 & EndDateUS<mdy(03, 04, 1853)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Taylor" if spillover==1 & EndDateUS<mdy(03, 09, 1850)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Polk" if spillover==1 & EndDateUS<mdy(03, 04, 1849)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Tyler" if spillover==1 & EndDateUS<mdy(03, 04, 1845)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "HarrisonWH" if spillover==1 & EndDateUS<mdy(04, 04, 1841)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Van_Buren" if spillover==1 & EndDateUS<mdy(03, 04, 1841)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Jackson" if spillover==1 & EndDateUS<mdy(03, 04, 1837)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Quincy_Adams" if spillover==1 & EndDateUS<mdy(03, 04, 1829)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Monroe"  if spillover==1 & EndDateUS<mdy(03, 04, 1825)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. replace Pres2 = "Madison" if spillover==1 & EndDateUS<mdy(03, 04, 1817)
{err}EndDateUS not found
{txt}{search r(111):r(111);}

{com}. 
. ** Merge with US presidents data using variable `varname'

. 
. gen varname=Pres1   

. sort varname

. 
. ** see presidentnames.xlsx for code for next section

. replace varname="madison" if varname=="Madison"
{txt}(0 real changes made)

{com}. replace varname="monroe" if varname=="Monroe"
{txt}(0 real changes made)

{com}. replace varname="adams2" if varname=="AdamsJQ"
{txt}(0 real changes made)

{com}. replace varname="jackson" if varname=="Jackson"
{txt}(0 real changes made)

{com}. replace varname="van_buren" if varname=="Van_Buren"
{txt}(0 real changes made)

{com}. replace varname="henry_harrison" if varname=="HarrisonWH"
{txt}(0 real changes made)

{com}. replace varname="tyler" if varname=="Tyler"
{txt}(0 real changes made)

{com}. replace varname="polk" if varname=="Polk"
{txt}(0 real changes made)

{com}. replace varname="taylor" if varname=="Taylor"
{txt}(0 real changes made)

{com}. replace varname="fillmore" if varname=="Fillmore"
{txt}(0 real changes made)

{com}. replace varname="pierce" if varname=="Pierce"
{txt}(0 real changes made)

{com}. replace varname="buchanan" if varname=="Buchanan"
{txt}(0 real changes made)

{com}. replace varname="lincoln" if varname=="Lincoln"
{txt}(0 real changes made)

{com}. replace varname="johnson1" if varname=="JohnsonA"
{txt}(0 real changes made)

{com}. replace varname="grant" if varname=="Grant"
{txt}(0 real changes made)

{com}. replace varname="hayes" if varname=="Hayes"
{txt}(0 real changes made)

{com}. replace varname="garfield" if varname=="Garfield"
{txt}(0 real changes made)

{com}. replace varname="arthur" if varname=="Arthur"
{txt}(0 real changes made)

{com}. replace varname="cleveland" if varname=="Cleveland1"
{txt}(0 real changes made)

{com}. replace varname="harrison2" if varname=="HarrisonB"
{txt}(0 real changes made)

{com}. replace varname="cleveland2" if varname=="Cleveland2"
{txt}(0 real changes made)

{com}. replace varname="mckinley" if varname=="McKinley"
{txt}(0 real changes made)

{com}. replace varname="roosevelt1" if varname=="RooseveltT"
{txt}(0 real changes made)

{com}. replace varname="taft" if varname=="Taft"
{txt}(0 real changes made)

{com}. replace varname="wilson" if varname=="Wilson"
{txt}(0 real changes made)

{com}. replace varname="harding" if varname=="Harding"
{txt}(0 real changes made)

{com}. replace varname="coolidge" if varname=="Coolidge"
{txt}(0 real changes made)

{com}. replace varname="hoover" if varname=="Hoover"
{txt}(0 real changes made)

{com}. replace varname="roosevelt2" if varname=="RooseveltFD"
{txt}(0 real changes made)

{com}. replace varname="truman" if varname=="Truman"
{txt}(0 real changes made)

{com}. replace varname="eisenhower" if varname=="Eisenhower"
{txt}(0 real changes made)

{com}. replace varname="kennedy" if varname=="Kennedy"
{txt}(0 real changes made)

{com}. replace varname="johnson2" if varname=="JohnsonLB"
{txt}(0 real changes made)

{com}. replace varname="nixon" if varname=="Nixon"
{txt}(0 real changes made)

{com}. replace varname="ford" if varname=="Ford"
{txt}(0 real changes made)

{com}. replace varname="carter" if varname=="Carter"
{txt}(0 real changes made)

{com}. replace varname="reagan" if varname=="Reagan"
{txt}(0 real changes made)

{com}. replace varname="bush1" if varname=="BushGHW"
{txt}(0 real changes made)

{com}. replace varname="clinton" if varname=="Clinton"
{txt}(0 real changes made)

{com}. replace varname="bush2" if varname=="BushGW"
{txt}(0 real changes made)

{com}. replace varname="obama" if varname=="Obama"
{txt}(0 real changes made)

{com}. 
. **Code produced in 2015-03-13 by Allan Dafoe and Devin Caughey

. 
. clear 

. 
. ** Set base working directory

. cd "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/"
{res}/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final

{com}. *cd "/Users/Allan/Dropbox/Shared/Work/Honor/2012-05/Replication-Final/"

. 
. log using "2-150317-data-merge-log.smcl", replace
{err}log file already open
{txt}{search r(604):r(604);}

{com}. 
. **** Load MID 4.01B data, downloaded from 

. **** http://www.correlatesofwar.org/data-sets/MIDs

. import delimited "1-Original-Data/MID-level/MIDB_4.01.csv"
{res}{text}(20 vars, 6132 obs)
{com}. 
. ** Drop MIDs not involving the US

. keep if ccode==2
{txt}(5760 observations deleted)

{com}. 
. sort dispnum3 dispnum4 ccode

. save "1-Original-Data/MIDB-US.dta", replace
{txt}file 1-Original-Data/MIDB-US.dta saved

{com}. 
. 
. **** Load MID 4.01A data

. clear

. import delimited "1-Original-Data/MID-level/MIDA_4.01.csv"
{res}{text}(24 vars, 2586 obs)
{com}. sort dispnum3 dispnum4

. save "1-Original-Data/MIDA.dta", replace
{txt}file 1-Original-Data/MIDA.dta saved

{com}. 
. 
. **** Merge MIDB and MIDA data

. clear

. use "1-Original-Data/MIDB-US.dta"

. merge 1:1 dispnum3 dispnum4 using "1-Original-Data/MIDA.dta", gen(mergeid)
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}           2,214
{txt}{col 9}from master{col 30}{res}               0{txt}  (mergeid==1)
{col 9}from using{col 30}{res}           2,214{txt}  (mergeid==2)

{col 5}matched{col 30}{res}             372{txt}  (mergeid==3)
{col 5}{hline 41}

{com}. 
. keep if mergeid==3
{txt}(2214 observations deleted)

{com}. drop mergeid

. 
. ** Generating start and end dates

. gen StartDateUS = mdy(stmon, stday, styear) 
{txt}(43 missing values generated)

{com}. gen EndDateUS = mdy(endmon, endday, endyear)
{txt}(45 missing values generated)

{com}. 
. ** If day is missing, replace day with 15th (an approximation)

. replace StartDateUS = mdy(stmon, 15, styear) if StartDateUS==.
{txt}(43 real changes made)

{com}. replace EndDateUS = mdy(endmon, 15, endyear) if EndDateUS==.
{txt}(45 real changes made)

{com}. 
. format StartDateUS EndDateUS %td 

. order StartDateUS EndDateUS

. 
. gen LngthMIDUS = EndDateUS - StartDateUS + 1

. 
. 
. **** Assigning Outcome

. rename outcome outcomeMID
{res}
{com}. gen outcome = .
{txt}(372 missing values generated)

{com}. 
. ** outcome = 1 if US has Victory or other side Yields

. replace outcome = 1 if sidea==1 & (outcomeMID==1 | outcomeMID==4)
{txt}(45 real changes made)

{com}. replace outcome = 1 if sidea==0 & (outcomeMID==2 | outcomeMID==3)
{txt}(15 real changes made)

{com}. 
. ** outcome = -1 if other has Victory or US Yields

. replace outcome = -1 if sidea==1 & (outcomeMID==2 | outcomeMID==3)
{txt}(7 real changes made)

{com}. replace outcome = -1 if sidea==0 & (outcomeMID==1 | outcomeMID==4)
{txt}(4 real changes made)

{com}. 
. ** outcome = 0 if other coding

. replace outcome = 0 if outcomeMID>4 | outcomeMID==. | outcomeMID < 0
{txt}(301 real changes made)

{com}. 
. ** Indicator for whether the US used force in the MID

. gen ForceUS = 0

. replace ForceUS = 1 if hostlev >= 4      
{txt}(126 real changes made)

{com}. 
. ** Ordering Variables: date, outcome variables, treatment, controls

. order StartDateUS EndDateUS outcome fatality LngthMIDUS ForceUS

. 
. 
. **** Generate President variables

. gen Pres1 = ""
{txt}(372 missing values generated)

{com}. order Pres1 EndDateUS StartDateUS

. 
. sort StartDateUS dispnum3 dispnum4

. 
. ** Assign presidents to MIDs

. replace Pres1 = "Madison" if StartDateUS>=mdy(03, 04, 1809) & EndDateUS<mdy(03, 04, 1817)
{txt}Pres1 was {res}str1{txt} now {res}str7
{txt}(1 real change made)

{com}. replace Pres1 = "Monroe"  if StartDateUS>=mdy(03, 04, 1817) & EndDateUS<mdy(03, 04, 1825)
{txt}(6 real changes made)

{com}. replace Pres1 = "AdamsJQ" if StartDateUS>=mdy(03, 04, 1825) & EndDateUS<mdy(03, 04, 1829)
{txt}(1 real change made)

{com}. replace Pres1 = "Jackson" if StartDateUS>=mdy(03, 04, 1829) & EndDateUS<mdy(03, 04, 1837)
{txt}(3 real changes made)

{com}. replace Pres1 = "Van_Buren" if StartDateUS>=mdy(03, 04, 1837) & EndDateUS<mdy(03, 04, 1841)
{txt}Pres1 was {res}str7{txt} now {res}str9
{txt}(4 real changes made)

{com}. replace Pres1 = "HarrisonWH" if StartDateUS>=mdy(03, 04, 1841) & EndDateUS<mdy(04, 04, 1841)
{txt}(0 real changes made)

{com}. replace Pres1 = "Tyler" if StartDateUS>=mdy(04, 04, 1841) & EndDateUS<mdy(03, 04, 1845)
{txt}(1 real change made)

{com}. replace Pres1 = "Polk" if StartDateUS>=mdy(03, 04, 1845) & EndDateUS<mdy(03, 04, 1849)
{txt}(1 real change made)

{com}. replace Pres1 = "Taylor" if StartDateUS>=mdy(03, 04, 1849) & EndDateUS<mdy(03, 09, 1850)
{txt}(0 real changes made)

{com}. replace Pres1 = "Fillmore" if StartDateUS>=mdy(03, 09, 1850) & EndDateUS<mdy(03, 04, 1853)
{txt}(3 real changes made)

{com}. replace Pres1 = "Pierce" if StartDateUS>=mdy(03, 04, 1853) & EndDateUS<mdy(03, 04, 1857)
{txt}(7 real changes made)

{com}. replace Pres1 = "Buchanan" if StartDateUS>=mdy(03, 04, 1857) & EndDateUS<mdy(03, 04, 1861)
{txt}(6 real changes made)

{com}. replace Pres1 = "Lincoln" if StartDateUS>=mdy(03, 04, 1861) & EndDateUS<mdy(04, 15, 1865)
{txt}(5 real changes made)

{com}. replace Pres1 = "JohnsonA" if StartDateUS>=mdy(04, 15, 1865) & EndDateUS<mdy(03, 04, 1869)
{txt}(5 real changes made)

{com}. replace Pres1 = "Grant" if StartDateUS>=mdy(03, 04, 1869) & EndDateUS<mdy(03, 04, 1877)
{txt}(7 real changes made)

{com}. replace Pres1 = "Hayes" if StartDateUS>=mdy(03, 04, 1877) & EndDateUS<mdy(03, 04, 1881)
{txt}(3 real changes made)

{com}. replace Pres1 = "Garfield" if StartDateUS>=mdy(03, 04, 1881) & EndDateUS<mdy(09, 19, 1881)
{txt}(0 real changes made)

{com}. replace Pres1 = "Arthur" if StartDateUS>=mdy(09, 19, 1881) & EndDateUS<mdy(03, 04, 1885)
{txt}(2 real changes made)

{com}. replace Pres1 = "Cleveland1" if StartDateUS>=mdy(03, 04, 1885) & EndDateUS<mdy(03, 04, 1889)
{txt}Pres1 was {res}str9{txt} now {res}str10
{txt}(5 real changes made)

{com}. replace Pres1 = "HarrisonB" if StartDateUS>=mdy(03, 04, 1889) & EndDateUS<mdy(03, 04, 1893)
{txt}(3 real changes made)

{com}. replace Pres1 = "Cleveland2" if StartDateUS>=mdy(03, 04, 1893) & EndDateUS<mdy(03, 04, 1897)
{txt}(5 real changes made)

{com}. replace Pres1 = "McKinley" if StartDateUS>=mdy(03, 04, 1897) & EndDateUS<mdy(09, 14, 1901)
{txt}(3 real changes made)

{com}. replace Pres1 = "RooseveltT" if StartDateUS>=mdy(09, 14, 1901) & EndDateUS<mdy(03, 04, 1909)
{txt}(9 real changes made)

{com}. replace Pres1 = "Taft" if StartDateUS>=mdy(03, 04, 1909) & EndDateUS<mdy(03, 04, 1913)
{txt}(5 real changes made)

{com}. replace Pres1 = "Wilson" if StartDateUS>=mdy(03, 04, 1913) & EndDateUS<mdy(03, 04, 1921)
{txt}(18 real changes made)

{com}. replace Pres1 = "Harding" if StartDateUS>=mdy(03, 04, 1921) & EndDateUS<mdy(08, 02, 1923)
{txt}(1 real change made)

{com}. replace Pres1 = "Coolidge" if StartDateUS>=mdy(08, 02, 1923) & EndDateUS<mdy(03, 04, 1929)
{txt}(3 real changes made)

{com}. replace Pres1 = "Hoover" if StartDateUS>=mdy(03, 04, 1929) & EndDateUS<mdy(03, 04, 1933)
{txt}(2 real changes made)

{com}. replace Pres1 = "RooseveltFD" if StartDateUS>=mdy(03, 04, 1933) & EndDateUS<mdy(04, 12, 1945)
{txt}Pres1 was {res}str10{txt} now {res}str11
{txt}(11 real changes made)

{com}. replace Pres1 = "Truman" if StartDateUS>=mdy(04, 12, 1945) & EndDateUS<mdy(01, 20, 1953)
{txt}(9 real changes made)

{com}. replace Pres1 = "Eisenhower" if StartDateUS>=mdy(01, 20, 1953) & EndDateUS<mdy(01, 20, 1961)
{txt}(33 real changes made)

{com}. replace Pres1 = "Kennedy" if StartDateUS>=mdy(01, 20, 1961) & EndDateUS<mdy(11, 22, 1963)
{txt}(14 real changes made)

{com}. replace Pres1 = "JohnsonLB" if StartDateUS>=mdy(11, 22, 1963) & EndDateUS<mdy(01, 20, 1969)
{txt}(21 real changes made)

{com}. replace Pres1 = "Nixon" if StartDateUS>=mdy(01, 20, 1969) & EndDateUS<mdy(08, 09, 1974)
{txt}(16 real changes made)

{com}. replace Pres1 = "Ford" if StartDateUS>=mdy(08, 09, 1974) & EndDateUS<mdy(01, 20, 1977)
{txt}(10 real changes made)

{com}. replace Pres1 = "Carter" if StartDateUS>=mdy(01, 20, 1977) & EndDateUS<mdy(01, 20, 1981)
{txt}(12 real changes made)

{com}. replace Pres1 = "Reagan" if StartDateUS>=mdy(01, 20, 1981) & EndDateUS<mdy(01, 20, 1989)
{txt}(43 real changes made)

{com}. replace Pres1 = "BushGHW" if StartDateUS>=mdy(01, 20, 1989) & EndDateUS<mdy(01, 20, 1993)
{txt}(8 real changes made)

{com}. replace Pres1 = "Clinton" if StartDateUS>=mdy(01, 20, 1993) & EndDateUS<mdy(01, 20, 2001)
{txt}(31 real changes made)

{com}. replace Pres1 = "BushGW" if StartDateUS>=mdy(01, 20, 2001) & EndDateUS<mdy(01, 20, 2009)
{txt}(25 real changes made)

{com}. replace Pres1 = "Obama" if StartDateUS>=mdy(01, 20, 2009) & EndDateUS<mdy(03, 13, 2015)
{txt}(5 real changes made)

{com}. 
. ** Note: Some MIDs spillover across Presidencies

. generate spillover = 0

. replace spillover = 1 if Pres1==""
{txt}(25 real changes made)

{com}. 
. ** Assigning spillover MIDs to first President to experience MID

. replace Pres1 = "Madison" if StartDateUS>=mdy(03, 04, 1809) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "Monroe"  if StartDateUS>=mdy(03, 04, 1817) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "AdamsJQ" if StartDateUS>=mdy(03, 04, 1825) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "Jackson" if StartDateUS>=mdy(03, 04, 1829) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "Van_Buren" if StartDateUS>=mdy(03, 04, 1837) & spillover==1
{txt}(24 real changes made)

{com}. replace Pres1 = "HarrisonWH" if StartDateUS>=mdy(03, 04, 1841) & spillover==1
{txt}(24 real changes made)

{com}. replace Pres1 = "Tyler" if StartDateUS>=mdy(04, 04, 1841) & spillover==1
{txt}(24 real changes made)

{com}. replace Pres1 = "Polk" if StartDateUS>=mdy(03, 04, 1845) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Taylor" if StartDateUS>=mdy(03, 04, 1849) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Fillmore" if StartDateUS>=mdy(03, 09, 1850) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Pierce" if StartDateUS>=mdy(03, 04, 1853) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Buchanan" if StartDateUS>=mdy(03, 04, 1857) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Lincoln" if StartDateUS>=mdy(03, 04, 1861) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "JohnsonA" if StartDateUS>=mdy(04, 15, 1865) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Grant" if StartDateUS>=mdy(03, 04, 1869) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Hayes" if StartDateUS>=mdy(03, 04, 1877) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "Garfield" if StartDateUS>=mdy(03, 04, 1881) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "Arthur" if StartDateUS>=mdy(09, 19, 1881) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "Cleveland1" if StartDateUS>=mdy(03, 04, 1885) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "HarrisonB" if StartDateUS>=mdy(03, 04, 1897) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "Cleveland2" if StartDateUS>=mdy(03, 04, 1893) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "McKinley" if StartDateUS>=mdy(03, 04, 1897) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "RooseveltT" if StartDateUS>=mdy(09, 14, 1901) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "Taft" if StartDateUS>=mdy(03, 04, 1909) & spillover==1
{txt}(20 real changes made)

{com}. replace Pres1 = "Wilson" if StartDateUS>=mdy(03, 04, 1913) & spillover==1
{txt}(20 real changes made)

{com}. replace Pres1 = "Harding" if StartDateUS>=mdy(03, 04, 1921) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "Coolidge" if StartDateUS>=mdy(08, 02, 1923) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "Hoover" if StartDateUS>=mdy(03, 04, 1929) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "RooseveltFD" if StartDateUS>=mdy(03, 04, 1933) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "Truman" if StartDateUS>=mdy(04, 12, 1945) & spillover==1
{txt}(18 real changes made)

{com}. replace Pres1 = "Eisenhower" if StartDateUS>=mdy(01, 20, 1953) & spillover==1
{txt}(17 real changes made)

{com}. replace Pres1 = "Kennedy" if StartDateUS>=mdy(01, 20, 1961) & spillover==1
{txt}(14 real changes made)

{com}. replace Pres1 = "JohnsonLB" if StartDateUS>=mdy(11, 22, 1963) & spillover==1
{txt}(12 real changes made)

{com}. replace Pres1 = "Nixon" if StartDateUS>=mdy(01, 20, 1969) & spillover==1
{txt}(9 real changes made)

{com}. replace Pres1 = "Ford" if StartDateUS>=mdy(08, 09, 1974) & spillover==1
{txt}(9 real changes made)

{com}. replace Pres1 = "Carter" if StartDateUS>=mdy(01, 20, 1977) & spillover==1
{txt}(9 real changes made)

{com}. replace Pres1 = "Reagan" if StartDateUS>=mdy(01, 20, 1981) & spillover==1
{txt}(7 real changes made)

{com}. replace Pres1 = "BushGHW" if StartDateUS>=mdy(01, 20, 1989) & spillover==1
{txt}(6 real changes made)

{com}. replace Pres1 = "Clinton" if StartDateUS>=mdy(01, 20, 1993) & spillover==1
{txt}(3 real changes made)

{com}. replace Pres1 = "BushGW" if StartDateUS>=mdy(01, 20, 2001) & spillover==1
{txt}(2 real changes made)

{com}. replace Pres1 = "Obama" if StartDateUS>=mdy(01, 20, 2009) & spillover==1
{txt}(0 real changes made)

{com}. 
. 
. ** Variable for the name of the President who was the first to inherit the MID

. gen Pres2 = ""
{txt}(372 missing values generated)

{com}. replace Pres2 = "Obama" if spillover==1 & EndDateUS<mdy(01, 20, 2013)
{txt}Pres2 was {res}str1{txt} now {res}str5
{txt}(25 real changes made)

{com}. replace Pres2 = "BushGW" if spillover==1 & EndDateUS<mdy(01, 20, 2009)
{txt}Pres2 was {res}str5{txt} now {res}str6
{txt}(23 real changes made)

{com}. replace Pres2 = "Clinton" if spillover==1 & EndDateUS<mdy(01, 20, 2001)
{txt}Pres2 was {res}str6{txt} now {res}str7
{txt}(22 real changes made)

{com}. replace Pres2 = "BushGHW" if spillover==1 & EndDateUS<mdy(01, 20, 1993)
{txt}(19 real changes made)

{com}. replace Pres2 = "Reagan" if spillover==1 & EndDateUS<mdy(01, 20, 1989)
{txt}(18 real changes made)

{com}. replace Pres2 = "Carter" if spillover==1 & EndDateUS<mdy(01, 20, 1981)
{txt}(16 real changes made)

{com}. replace Pres2 = "Ford" if spillover==1 & EndDateUS<mdy(01, 20, 1977)
{txt}(16 real changes made)

{com}. replace Pres2 = "Nixon" if spillover==1 & EndDateUS<mdy(08, 09, 1974)
{txt}(16 real changes made)

{com}. replace Pres2 = "JohnsonLB" if spillover==1 & EndDateUS<mdy(01, 20, 1969)
{txt}Pres2 was {res}str7{txt} now {res}str9
{txt}(12 real changes made)

{com}. replace Pres2 = "Kennedy" if spillover==1 & EndDateUS<mdy(11, 22, 1963)
{txt}(11 real changes made)

{com}. replace Pres2 = "Eisenhower" if spillover==1 & EndDateUS<mdy(01, 20, 1961)
{txt}Pres2 was {res}str9{txt} now {res}str10
{txt}(8 real changes made)

{com}. replace Pres2 = "Truman" if spillover==1 & EndDateUS<mdy(01, 20, 1953)
{txt}(7 real changes made)

{com}. replace Pres2 = "RooseveltFD" if spillover==1 & EndDateUS<mdy(04, 12, 1945)
{txt}Pres2 was {res}str10{txt} now {res}str11
{txt}(6 real changes made)

{com}. replace Pres2 = "Hoover" if spillover==1 & EndDateUS<mdy(03, 04, 1933)
{txt}(6 real changes made)

{com}. replace Pres2 = "Coolidge" if spillover==1 & EndDateUS<mdy(03, 04, 1929)
{txt}(6 real changes made)

{com}. replace Pres2 = "Harding" if spillover==1 & EndDateUS<mdy(08, 02, 1923)
{txt}(6 real changes made)

{com}. replace Pres2 = "Wilson" if spillover==1 & EndDateUS<mdy(03, 04, 1921)
{txt}(5 real changes made)

{com}. replace Pres2 = "Taft" if spillover==1 & EndDateUS<mdy(03, 04, 1913)
{txt}(5 real changes made)

{com}. replace Pres2 = "RooseveltT" if spillover==1 & EndDateUS<mdy(03, 04, 1909)
{txt}(4 real changes made)

{com}. replace Pres2 = "McKinley" if spillover==1 & EndDateUS<mdy(09, 14, 1901)
{txt}(4 real changes made)

{com}. replace Pres2 = "Cleveland2" if spillover==1 & EndDateUS<mdy(03, 04, 1897)
{txt}(4 real changes made)

{com}. replace Pres2 = "HarrisonB" if spillover==1 & EndDateUS<mdy(03, 04, 1893)
{txt}(4 real changes made)

{com}. replace Pres2 = "Cleveland1" if spillover==1 & EndDateUS<mdy(03, 04, 1889)
{txt}(3 real changes made)

{com}. replace Pres2 = "Arthur" if spillover==1 & EndDateUS<mdy(03, 04, 1885)
{txt}(3 real changes made)

{com}. replace Pres2 = "Garfield" if spillover==1 & EndDateUS<mdy(09, 19, 1881)
{txt}(3 real changes made)

{com}. replace Pres2 = "Hayes" if spillover==1 & EndDateUS<mdy(03, 04, 1881)
{txt}(3 real changes made)

{com}. replace Pres2 = "Grant" if spillover==1 & EndDateUS<mdy(03, 04, 1877)
{txt}(2 real changes made)

{com}. replace Pres2 = "JohnsonA" if spillover==1 & EndDateUS<mdy(03, 04, 1869)
{txt}(2 real changes made)

{com}. replace Pres2 = "Lincoln" if spillover==1 & EndDateUS<mdy(04, 15, 1865)
{txt}(2 real changes made)

{com}. replace Pres2 = "Buchanan" if spillover==1& EndDateUS<mdy(03, 04, 1861)
{txt}(2 real changes made)

{com}. replace Pres2 = "Pierce" if spillover==1 & EndDateUS<mdy(03, 04, 1857)
{txt}(2 real changes made)

{com}. replace Pres2 = "Fillmore" if spillover==1 & EndDateUS<mdy(03, 04, 1853)
{txt}(2 real changes made)

{com}. replace Pres2 = "Taylor" if spillover==1 & EndDateUS<mdy(03, 09, 1850)
{txt}(2 real changes made)

{com}. replace Pres2 = "Polk" if spillover==1 & EndDateUS<mdy(03, 04, 1849)
{txt}(2 real changes made)

{com}. replace Pres2 = "Tyler" if spillover==1 & EndDateUS<mdy(03, 04, 1845)
{txt}(1 real change made)

{com}. replace Pres2 = "HarrisonWH" if spillover==1 & EndDateUS<mdy(04, 04, 1841)
{txt}(1 real change made)

{com}. replace Pres2 = "Van_Buren" if spillover==1 & EndDateUS<mdy(03, 04, 1841)
{txt}(1 real change made)

{com}. replace Pres2 = "Jackson" if spillover==1 & EndDateUS<mdy(03, 04, 1837)
{txt}(0 real changes made)

{com}. replace Pres2 = "Quincy_Adams" if spillover==1 & EndDateUS<mdy(03, 04, 1829)
{txt}(0 real changes made)

{com}. replace Pres2 = "Monroe"  if spillover==1 & EndDateUS<mdy(03, 04, 1825)
{txt}(0 real changes made)

{com}. replace Pres2 = "Madison" if spillover==1 & EndDateUS<mdy(03, 04, 1817)
{txt}(0 real changes made)

{com}. 
. ** Merge with US presidents data using variable `varname'

. 
. gen varname=Pres1   

. sort varname

. 
. ** see presidentnames.xlsx for code for next section

. replace varname="madison" if varname=="Madison"
{txt}(1 real change made)

{com}. replace varname="monroe" if varname=="Monroe"
{txt}(6 real changes made)

{com}. replace varname="adams2" if varname=="AdamsJQ"
{txt}(1 real change made)

{com}. replace varname="jackson" if varname=="Jackson"
{txt}(4 real changes made)

{com}. replace varname="van_buren" if varname=="Van_Buren"
{txt}(4 real changes made)

{com}. replace varname="harrison1" if varname=="HarrisonWH"
{txt}(0 real changes made)

{com}. replace varname="tyler" if varname=="Tyler"
{txt}(2 real changes made)

{com}. replace varname="polk" if varname=="Polk"
{txt}(1 real change made)

{com}. replace varname="taylor" if varname=="Taylor"
{txt}(0 real changes made)

{com}. replace varname="fillmore" if varname=="Fillmore"
{txt}(3 real changes made)

{com}. replace varname="pierce" if varname=="Pierce"
{txt}(7 real changes made)

{com}. replace varname="buchanan" if varname=="Buchanan"
{txt}(6 real changes made)

{com}. replace varname="lincoln" if varname=="Lincoln"
{txt}(5 real changes made)

{com}. replace varname="johnson1" if varname=="JohnsonA"
{txt}(5 real changes made)

{com}. replace varname="grant" if varname=="Grant"
{txt}(8 real changes made)

{com}. replace varname="hayes" if varname=="Hayes"
{txt}(3 real changes made)

{com}. replace varname="garfield" if varname=="Garfield"
{txt}(0 real changes made)

{com}. replace varname="arthur" if varname=="Arthur"
{txt}(2 real changes made)

{com}. replace varname="cleveland" if varname=="Cleveland1"
{txt}(6 real changes made)

{com}. replace varname="harrison2" if varname=="HarrisonB"
{txt}(3 real changes made)

{com}. replace varname="cleveland2" if varname=="Cleveland2"
{txt}(5 real changes made)

{com}. replace varname="mckinley" if varname=="McKinley"
{txt}(3 real changes made)

{com}. replace varname="roosevelt1" if varname=="RooseveltT"
{txt}(10 real changes made)

{com}. replace varname="taft" if varname=="Taft"
{txt}(5 real changes made)

{com}. replace varname="wilson" if varname=="Wilson"
{txt}(19 real changes made)

{com}. replace varname="harding" if varname=="Harding"
{txt}(1 real change made)

{com}. replace varname="coolidge" if varname=="Coolidge"
{txt}(3 real changes made)

{com}. replace varname="hoover" if varname=="Hoover"
{txt}(2 real changes made)

{com}. replace varname="roosevelt2" if varname=="RooseveltFD"
{txt}(12 real changes made)

{com}. replace varname="truman" if varname=="Truman"
{txt}(10 real changes made)

{com}. replace varname="eisenhower" if varname=="Eisenhower"
{txt}(36 real changes made)

{com}. replace varname="kennedy" if varname=="Kennedy"
{txt}(16 real changes made)

{com}. replace varname="johnson2" if varname=="JohnsonLB"
{txt}(24 real changes made)

{com}. replace varname="nixon" if varname=="Nixon"
{txt}(16 real changes made)

{com}. replace varname="ford" if varname=="Ford"
{txt}(10 real changes made)

{com}. replace varname="carter" if varname=="Carter"
{txt}(14 real changes made)

{com}. replace varname="reagan" if varname=="Reagan"
{txt}(44 real changes made)

{com}. replace varname="bush1" if varname=="BushGHW"
{txt}(11 real changes made)

{com}. replace varname="clinton" if varname=="Clinton"
{txt}(32 real changes made)

{com}. replace varname="bush2" if varname=="BushGW"
{txt}(27 real changes made)

{com}. replace varname="obama" if varname=="Obama"
{txt}(5 real changes made)

{com}. 
. clear

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta"

. browse

. order South

. browse

. clear

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication/MergedDatasets/USMIDs2010-10-30AltSouth1.dta"

. browse

. clear

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication/MergedDatasets/USMIDs2010-10-30AltSouth2.dta"

. browse

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication/MergedDatasets/USMIDs2010-10-30AltSouth3.dta"

. browse

. (mdy(11, 1, 2001) - mdy(3, 1, 2001)) + (mdy(1, 20, 2009) - mdy(12, 1, 2007))
{err}unrecognized command:  ( invalid command name
{txt}{search r(199):r(199);}

{com}. mdy(11, 1, 2001) - mdy(3, 1, 2001)) + (mdy(1, 20, 2009) - mdy(12, 1, 2007)
{err}unrecognized command:  mdy
{txt}{search r(199):r(199);}

{com}. gen datevar = (mdy(11, 1, 2001) - mdy(3, 1, 2001)) + (mdy(1, 20, 2009) - mdy(12, 1, 2007))

. order datevar

. browse

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta", clear

. edit

. clear

. gen datevar = (mdy(11, 1, 2001) - mdy(3, 1, 2001)) + (mdy(1, 20, 2009) - mdy(12, 1, 2007))

. browse

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication/MergedDatasets/USMID
{err}no; data in memory would be lost
{txt}{search r(4):r(4);}

{com}. > s2010-10-30AltSouth3.dta"
{err}unrecognized command:  > invalid command name
{txt}{search r(199):r(199);}

{com}. 
. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta", clear

.  gen datevar = (mdy(11, 1, 2001) - mdy(3, 1, 2001)) + (mdy(1, 20, 2009) - mdy(12, 1, 2007))

. order datevar

. browse

. clear

. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta"

. edit

. replace daysrec = 661 in 43
{txt}(1 real change made)

{com}. save "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta", replace
{txt}file /Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta saved

{com}. gen testvar = mdy(6, 1, 2009) - mdy(1, 20, 2009)

. order testvar

. browse

. edit

. replace daysrec = 660 in 43
{txt}(1 real change made)

{com}. save "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta", replace
{txt}file /Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta saved

{com}. drop testvar

. save "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta", replace
{txt}file /Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/USPres2010-10-13.dta saved

{com}. use "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/MIDB-US.dta"

. tab sidea orig

           {txt}{c |}         Orig
     SideA {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}        41        128 {txt}{c |}{res}       169 
{txt}         1 {c |}{res}        15        188 {txt}{c |}{res}       203 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}        56        316 {txt}{c |}{res}       372 


{com}. **Code produced in 2015-03-13 by Allan Dafoe and Devin Caughey

. 
. clear 

. 
. ** Set base working directory

. cd "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/"
{res}/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final

{com}. 
. log using "2-150317-data-merge-log.smcl", replace
{err}log file already open
{txt}{search r(604):r(604);}

{com}. 
. **** Load MID 4.01B data, downloaded from 

. **** http://www.correlatesofwar.org/data-sets/MIDs

. import delimited "1-Original-Data/MID-level/MIDB_4.01.csv"
{res}{text}(20 vars, 6132 obs)
{com}. 
. ** Drop MIDs not involving the US

. keep if ccode==2
{txt}(5760 observations deleted)

{com}. 
. sort dispnum3 dispnum4 ccode

. save "1-Original-Data/MIDB-US.dta", replace
{txt}file 1-Original-Data/MIDB-US.dta saved

{com}. 
. 
. **** Load MID 4.01A data

. clear

. import delimited "1-Original-Data/MID-level/MIDA_4.01.csv"
{res}{text}(24 vars, 2586 obs)
{com}. sort dispnum3 dispnum4

. save "1-Original-Data/MIDA.dta", replace
{txt}file 1-Original-Data/MIDA.dta saved

{com}. 
. 
. **** Merge MIDB and MIDA data

. clear

. use "1-Original-Data/MIDB-US.dta"

. merge 1:1 dispnum3 dispnum4 using "1-Original-Data/MIDA.dta", gen(mergeid)
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}           2,214
{txt}{col 9}from master{col 30}{res}               0{txt}  (mergeid==1)
{col 9}from using{col 30}{res}           2,214{txt}  (mergeid==2)

{col 5}matched{col 30}{res}             372{txt}  (mergeid==3)
{col 5}{hline 41}

{com}. 
. keep if mergeid==3
{txt}(2214 observations deleted)

{com}. drop mergeid

. 
. ** Generating start and end dates

. gen StartDateUS = mdy(stmon, stday, styear) 
{txt}(43 missing values generated)

{com}. gen EndDateUS = mdy(endmon, endday, endyear)
{txt}(45 missing values generated)

{com}. 
. ** If day is missing, replace day with 15th (an approximation)

. replace StartDateUS = mdy(stmon, 15, styear) if StartDateUS==.
{txt}(43 real changes made)

{com}. replace EndDateUS = mdy(endmon, 15, endyear) if EndDateUS==.
{txt}(45 real changes made)

{com}. 
. format StartDateUS EndDateUS %td 

. order StartDateUS EndDateUS

. 
. gen LngthMIDUS = EndDateUS - StartDateUS + 1

. 
. 
. **** Assigning Outcome

. rename outcome outcomeMID
{res}
{com}. gen outcome = .
{txt}(372 missing values generated)

{com}. 
. ** outcome = 1 if US has Victory or other side Yields

. replace outcome = 1 if sidea==1 & (outcomeMID==1 | outcomeMID==4)
{txt}(45 real changes made)

{com}. replace outcome = 1 if sidea==0 & (outcomeMID==2 | outcomeMID==3)
{txt}(15 real changes made)

{com}. 
. ** outcome = -1 if other has Victory or US Yields

. replace outcome = -1 if sidea==1 & (outcomeMID==2 | outcomeMID==3)
{txt}(7 real changes made)

{com}. replace outcome = -1 if sidea==0 & (outcomeMID==1 | outcomeMID==4)
{txt}(4 real changes made)

{com}. 
. ** outcome = 0 if other coding

. replace outcome = 0 if outcomeMID>4 | outcomeMID==. | outcomeMID < 0
{txt}(301 real changes made)

{com}. 
. ** Indicator for whether the US used force in the MID

. gen ForceUS = 0

. replace ForceUS = 1 if hostlev >= 4      
{txt}(126 real changes made)

{com}. 
. ** Ordering Variables: date, outcome variables, treatment, controls

. order StartDateUS EndDateUS outcome fatality LngthMIDUS ForceUS

. 
. 
. **** Generate President variables

. gen Pres1 = ""
{txt}(372 missing values generated)

{com}. order Pres1 EndDateUS StartDateUS

. 
. sort StartDateUS dispnum3 dispnum4

. 
. ** Assign presidents to MIDs

. replace Pres1 = "Madison" if StartDateUS>=mdy(03, 04, 1809) & EndDateUS<mdy(03, 04, 1817)
{txt}Pres1 was {res}str1{txt} now {res}str7
{txt}(1 real change made)

{com}. replace Pres1 = "Monroe"  if StartDateUS>=mdy(03, 04, 1817) & EndDateUS<mdy(03, 04, 1825)
{txt}(6 real changes made)

{com}. replace Pres1 = "AdamsJQ" if StartDateUS>=mdy(03, 04, 1825) & EndDateUS<mdy(03, 04, 1829)
{txt}(1 real change made)

{com}. replace Pres1 = "Jackson" if StartDateUS>=mdy(03, 04, 1829) & EndDateUS<mdy(03, 04, 1837)
{txt}(3 real changes made)

{com}. replace Pres1 = "Van_Buren" if StartDateUS>=mdy(03, 04, 1837) & EndDateUS<mdy(03, 04, 1841)
{txt}Pres1 was {res}str7{txt} now {res}str9
{txt}(4 real changes made)

{com}. replace Pres1 = "HarrisonWH" if StartDateUS>=mdy(03, 04, 1841) & EndDateUS<mdy(04, 04, 1841)
{txt}(0 real changes made)

{com}. replace Pres1 = "Tyler" if StartDateUS>=mdy(04, 04, 1841) & EndDateUS<mdy(03, 04, 1845)
{txt}(1 real change made)

{com}. replace Pres1 = "Polk" if StartDateUS>=mdy(03, 04, 1845) & EndDateUS<mdy(03, 04, 1849)
{txt}(1 real change made)

{com}. replace Pres1 = "Taylor" if StartDateUS>=mdy(03, 04, 1849) & EndDateUS<mdy(03, 09, 1850)
{txt}(0 real changes made)

{com}. replace Pres1 = "Fillmore" if StartDateUS>=mdy(03, 09, 1850) & EndDateUS<mdy(03, 04, 1853)
{txt}(3 real changes made)

{com}. replace Pres1 = "Pierce" if StartDateUS>=mdy(03, 04, 1853) & EndDateUS<mdy(03, 04, 1857)
{txt}(7 real changes made)

{com}. replace Pres1 = "Buchanan" if StartDateUS>=mdy(03, 04, 1857) & EndDateUS<mdy(03, 04, 1861)
{txt}(6 real changes made)

{com}. replace Pres1 = "Lincoln" if StartDateUS>=mdy(03, 04, 1861) & EndDateUS<mdy(04, 15, 1865)
{txt}(5 real changes made)

{com}. replace Pres1 = "JohnsonA" if StartDateUS>=mdy(04, 15, 1865) & EndDateUS<mdy(03, 04, 1869)
{txt}(5 real changes made)

{com}. replace Pres1 = "Grant" if StartDateUS>=mdy(03, 04, 1869) & EndDateUS<mdy(03, 04, 1877)
{txt}(7 real changes made)

{com}. replace Pres1 = "Hayes" if StartDateUS>=mdy(03, 04, 1877) & EndDateUS<mdy(03, 04, 1881)
{txt}(3 real changes made)

{com}. replace Pres1 = "Garfield" if StartDateUS>=mdy(03, 04, 1881) & EndDateUS<mdy(09, 19, 1881)
{txt}(0 real changes made)

{com}. replace Pres1 = "Arthur" if StartDateUS>=mdy(09, 19, 1881) & EndDateUS<mdy(03, 04, 1885)
{txt}(2 real changes made)

{com}. replace Pres1 = "Cleveland1" if StartDateUS>=mdy(03, 04, 1885) & EndDateUS<mdy(03, 04, 1889)
{txt}Pres1 was {res}str9{txt} now {res}str10
{txt}(5 real changes made)

{com}. replace Pres1 = "HarrisonB" if StartDateUS>=mdy(03, 04, 1889) & EndDateUS<mdy(03, 04, 1893)
{txt}(3 real changes made)

{com}. replace Pres1 = "Cleveland2" if StartDateUS>=mdy(03, 04, 1893) & EndDateUS<mdy(03, 04, 1897)
{txt}(5 real changes made)

{com}. replace Pres1 = "McKinley" if StartDateUS>=mdy(03, 04, 1897) & EndDateUS<mdy(09, 14, 1901)
{txt}(3 real changes made)

{com}. replace Pres1 = "RooseveltT" if StartDateUS>=mdy(09, 14, 1901) & EndDateUS<mdy(03, 04, 1909)
{txt}(9 real changes made)

{com}. replace Pres1 = "Taft" if StartDateUS>=mdy(03, 04, 1909) & EndDateUS<mdy(03, 04, 1913)
{txt}(5 real changes made)

{com}. replace Pres1 = "Wilson" if StartDateUS>=mdy(03, 04, 1913) & EndDateUS<mdy(03, 04, 1921)
{txt}(18 real changes made)

{com}. replace Pres1 = "Harding" if StartDateUS>=mdy(03, 04, 1921) & EndDateUS<mdy(08, 02, 1923)
{txt}(1 real change made)

{com}. replace Pres1 = "Coolidge" if StartDateUS>=mdy(08, 02, 1923) & EndDateUS<mdy(03, 04, 1929)
{txt}(3 real changes made)

{com}. replace Pres1 = "Hoover" if StartDateUS>=mdy(03, 04, 1929) & EndDateUS<mdy(03, 04, 1933)
{txt}(2 real changes made)

{com}. replace Pres1 = "RooseveltFD" if StartDateUS>=mdy(03, 04, 1933) & EndDateUS<mdy(04, 12, 1945)
{txt}Pres1 was {res}str10{txt} now {res}str11
{txt}(11 real changes made)

{com}. replace Pres1 = "Truman" if StartDateUS>=mdy(04, 12, 1945) & EndDateUS<mdy(01, 20, 1953)
{txt}(9 real changes made)

{com}. replace Pres1 = "Eisenhower" if StartDateUS>=mdy(01, 20, 1953) & EndDateUS<mdy(01, 20, 1961)
{txt}(33 real changes made)

{com}. replace Pres1 = "Kennedy" if StartDateUS>=mdy(01, 20, 1961) & EndDateUS<mdy(11, 22, 1963)
{txt}(14 real changes made)

{com}. replace Pres1 = "JohnsonLB" if StartDateUS>=mdy(11, 22, 1963) & EndDateUS<mdy(01, 20, 1969)
{txt}(21 real changes made)

{com}. replace Pres1 = "Nixon" if StartDateUS>=mdy(01, 20, 1969) & EndDateUS<mdy(08, 09, 1974)
{txt}(16 real changes made)

{com}. replace Pres1 = "Ford" if StartDateUS>=mdy(08, 09, 1974) & EndDateUS<mdy(01, 20, 1977)
{txt}(10 real changes made)

{com}. replace Pres1 = "Carter" if StartDateUS>=mdy(01, 20, 1977) & EndDateUS<mdy(01, 20, 1981)
{txt}(12 real changes made)

{com}. replace Pres1 = "Reagan" if StartDateUS>=mdy(01, 20, 1981) & EndDateUS<mdy(01, 20, 1989)
{txt}(43 real changes made)

{com}. replace Pres1 = "BushGHW" if StartDateUS>=mdy(01, 20, 1989) & EndDateUS<mdy(01, 20, 1993)
{txt}(8 real changes made)

{com}. replace Pres1 = "Clinton" if StartDateUS>=mdy(01, 20, 1993) & EndDateUS<mdy(01, 20, 2001)
{txt}(31 real changes made)

{com}. replace Pres1 = "BushGW" if StartDateUS>=mdy(01, 20, 2001) & EndDateUS<mdy(01, 20, 2009)
{txt}(25 real changes made)

{com}. replace Pres1 = "Obama" if StartDateUS>=mdy(01, 20, 2009) & EndDateUS<mdy(03, 13, 2015)
{txt}(5 real changes made)

{com}. 
. ** Note: Some MIDs spillover across Presidencies

. generate spillover = 0

. replace spillover = 1 if Pres1==""
{txt}(25 real changes made)

{com}. 
. ** Assigning spillover MIDs to first President to experience MID

. replace Pres1 = "Madison" if StartDateUS>=mdy(03, 04, 1809) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "Monroe"  if StartDateUS>=mdy(03, 04, 1817) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "AdamsJQ" if StartDateUS>=mdy(03, 04, 1825) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "Jackson" if StartDateUS>=mdy(03, 04, 1829) & spillover==1
{txt}(25 real changes made)

{com}. replace Pres1 = "Van_Buren" if StartDateUS>=mdy(03, 04, 1837) & spillover==1
{txt}(24 real changes made)

{com}. replace Pres1 = "HarrisonWH" if StartDateUS>=mdy(03, 04, 1841) & spillover==1
{txt}(24 real changes made)

{com}. replace Pres1 = "Tyler" if StartDateUS>=mdy(04, 04, 1841) & spillover==1
{txt}(24 real changes made)

{com}. replace Pres1 = "Polk" if StartDateUS>=mdy(03, 04, 1845) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Taylor" if StartDateUS>=mdy(03, 04, 1849) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Fillmore" if StartDateUS>=mdy(03, 09, 1850) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Pierce" if StartDateUS>=mdy(03, 04, 1853) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Buchanan" if StartDateUS>=mdy(03, 04, 1857) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Lincoln" if StartDateUS>=mdy(03, 04, 1861) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "JohnsonA" if StartDateUS>=mdy(04, 15, 1865) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Grant" if StartDateUS>=mdy(03, 04, 1869) & spillover==1
{txt}(23 real changes made)

{com}. replace Pres1 = "Hayes" if StartDateUS>=mdy(03, 04, 1877) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "Garfield" if StartDateUS>=mdy(03, 04, 1881) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "Arthur" if StartDateUS>=mdy(09, 19, 1881) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "Cleveland1" if StartDateUS>=mdy(03, 04, 1885) & spillover==1
{txt}(22 real changes made)

{com}. replace Pres1 = "HarrisonB" if StartDateUS>=mdy(03, 04, 1897) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "Cleveland2" if StartDateUS>=mdy(03, 04, 1893) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "McKinley" if StartDateUS>=mdy(03, 04, 1897) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "RooseveltT" if StartDateUS>=mdy(09, 14, 1901) & spillover==1
{txt}(21 real changes made)

{com}. replace Pres1 = "Taft" if StartDateUS>=mdy(03, 04, 1909) & spillover==1
{txt}(20 real changes made)

{com}. replace Pres1 = "Wilson" if StartDateUS>=mdy(03, 04, 1913) & spillover==1
{txt}(20 real changes made)

{com}. replace Pres1 = "Harding" if StartDateUS>=mdy(03, 04, 1921) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "Coolidge" if StartDateUS>=mdy(08, 02, 1923) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "Hoover" if StartDateUS>=mdy(03, 04, 1929) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "RooseveltFD" if StartDateUS>=mdy(03, 04, 1933) & spillover==1
{txt}(19 real changes made)

{com}. replace Pres1 = "Truman" if StartDateUS>=mdy(04, 12, 1945) & spillover==1
{txt}(18 real changes made)

{com}. replace Pres1 = "Eisenhower" if StartDateUS>=mdy(01, 20, 1953) & spillover==1
{txt}(17 real changes made)

{com}. replace Pres1 = "Kennedy" if StartDateUS>=mdy(01, 20, 1961) & spillover==1
{txt}(14 real changes made)

{com}. replace Pres1 = "JohnsonLB" if StartDateUS>=mdy(11, 22, 1963) & spillover==1
{txt}(12 real changes made)

{com}. replace Pres1 = "Nixon" if StartDateUS>=mdy(01, 20, 1969) & spillover==1
{txt}(9 real changes made)

{com}. replace Pres1 = "Ford" if StartDateUS>=mdy(08, 09, 1974) & spillover==1
{txt}(9 real changes made)

{com}. replace Pres1 = "Carter" if StartDateUS>=mdy(01, 20, 1977) & spillover==1
{txt}(9 real changes made)

{com}. replace Pres1 = "Reagan" if StartDateUS>=mdy(01, 20, 1981) & spillover==1
{txt}(7 real changes made)

{com}. replace Pres1 = "BushGHW" if StartDateUS>=mdy(01, 20, 1989) & spillover==1
{txt}(6 real changes made)

{com}. replace Pres1 = "Clinton" if StartDateUS>=mdy(01, 20, 1993) & spillover==1
{txt}(3 real changes made)

{com}. replace Pres1 = "BushGW" if StartDateUS>=mdy(01, 20, 2001) & spillover==1
{txt}(2 real changes made)

{com}. replace Pres1 = "Obama" if StartDateUS>=mdy(01, 20, 2009) & spillover==1
{txt}(0 real changes made)

{com}. 
. 
. ** Variable for the name of the President who was the first to inherit the MID

. gen Pres2 = ""
{txt}(372 missing values generated)

{com}. replace Pres2 = "Obama" if spillover==1 & EndDateUS<mdy(01, 20, 2013)
{txt}Pres2 was {res}str1{txt} now {res}str5
{txt}(25 real changes made)

{com}. replace Pres2 = "BushGW" if spillover==1 & EndDateUS<mdy(01, 20, 2009)
{txt}Pres2 was {res}str5{txt} now {res}str6
{txt}(23 real changes made)

{com}. replace Pres2 = "Clinton" if spillover==1 & EndDateUS<mdy(01, 20, 2001)
{txt}Pres2 was {res}str6{txt} now {res}str7
{txt}(22 real changes made)

{com}. replace Pres2 = "BushGHW" if spillover==1 & EndDateUS<mdy(01, 20, 1993)
{txt}(19 real changes made)

{com}. replace Pres2 = "Reagan" if spillover==1 & EndDateUS<mdy(01, 20, 1989)
{txt}(18 real changes made)

{com}. replace Pres2 = "Carter" if spillover==1 & EndDateUS<mdy(01, 20, 1981)
{txt}(16 real changes made)

{com}. replace Pres2 = "Ford" if spillover==1 & EndDateUS<mdy(01, 20, 1977)
{txt}(16 real changes made)

{com}. replace Pres2 = "Nixon" if spillover==1 & EndDateUS<mdy(08, 09, 1974)
{txt}(16 real changes made)

{com}. replace Pres2 = "JohnsonLB" if spillover==1 & EndDateUS<mdy(01, 20, 1969)
{txt}Pres2 was {res}str7{txt} now {res}str9
{txt}(12 real changes made)

{com}. replace Pres2 = "Kennedy" if spillover==1 & EndDateUS<mdy(11, 22, 1963)
{txt}(11 real changes made)

{com}. replace Pres2 = "Eisenhower" if spillover==1 & EndDateUS<mdy(01, 20, 1961)
{txt}Pres2 was {res}str9{txt} now {res}str10
{txt}(8 real changes made)

{com}. replace Pres2 = "Truman" if spillover==1 & EndDateUS<mdy(01, 20, 1953)
{txt}(7 real changes made)

{com}. replace Pres2 = "RooseveltFD" if spillover==1 & EndDateUS<mdy(04, 12, 1945)
{txt}Pres2 was {res}str10{txt} now {res}str11
{txt}(6 real changes made)

{com}. replace Pres2 = "Hoover" if spillover==1 & EndDateUS<mdy(03, 04, 1933)
{txt}(6 real changes made)

{com}. replace Pres2 = "Coolidge" if spillover==1 & EndDateUS<mdy(03, 04, 1929)
{txt}(6 real changes made)

{com}. replace Pres2 = "Harding" if spillover==1 & EndDateUS<mdy(08, 02, 1923)
{txt}(6 real changes made)

{com}. replace Pres2 = "Wilson" if spillover==1 & EndDateUS<mdy(03, 04, 1921)
{txt}(5 real changes made)

{com}. replace Pres2 = "Taft" if spillover==1 & EndDateUS<mdy(03, 04, 1913)
{txt}(5 real changes made)

{com}. replace Pres2 = "RooseveltT" if spillover==1 & EndDateUS<mdy(03, 04, 1909)
{txt}(4 real changes made)

{com}. replace Pres2 = "McKinley" if spillover==1 & EndDateUS<mdy(09, 14, 1901)
{txt}(4 real changes made)

{com}. replace Pres2 = "Cleveland2" if spillover==1 & EndDateUS<mdy(03, 04, 1897)
{txt}(4 real changes made)

{com}. replace Pres2 = "HarrisonB" if spillover==1 & EndDateUS<mdy(03, 04, 1893)
{txt}(4 real changes made)

{com}. replace Pres2 = "Cleveland1" if spillover==1 & EndDateUS<mdy(03, 04, 1889)
{txt}(3 real changes made)

{com}. replace Pres2 = "Arthur" if spillover==1 & EndDateUS<mdy(03, 04, 1885)
{txt}(3 real changes made)

{com}. replace Pres2 = "Garfield" if spillover==1 & EndDateUS<mdy(09, 19, 1881)
{txt}(3 real changes made)

{com}. replace Pres2 = "Hayes" if spillover==1 & EndDateUS<mdy(03, 04, 1881)
{txt}(3 real changes made)

{com}. replace Pres2 = "Grant" if spillover==1 & EndDateUS<mdy(03, 04, 1877)
{txt}(2 real changes made)

{com}. replace Pres2 = "JohnsonA" if spillover==1 & EndDateUS<mdy(03, 04, 1869)
{txt}(2 real changes made)

{com}. replace Pres2 = "Lincoln" if spillover==1 & EndDateUS<mdy(04, 15, 1865)
{txt}(2 real changes made)

{com}. replace Pres2 = "Buchanan" if spillover==1& EndDateUS<mdy(03, 04, 1861)
{txt}(2 real changes made)

{com}. replace Pres2 = "Pierce" if spillover==1 & EndDateUS<mdy(03, 04, 1857)
{txt}(2 real changes made)

{com}. replace Pres2 = "Fillmore" if spillover==1 & EndDateUS<mdy(03, 04, 1853)
{txt}(2 real changes made)

{com}. replace Pres2 = "Taylor" if spillover==1 & EndDateUS<mdy(03, 09, 1850)
{txt}(2 real changes made)

{com}. replace Pres2 = "Polk" if spillover==1 & EndDateUS<mdy(03, 04, 1849)
{txt}(2 real changes made)

{com}. replace Pres2 = "Tyler" if spillover==1 & EndDateUS<mdy(03, 04, 1845)
{txt}(1 real change made)

{com}. replace Pres2 = "HarrisonWH" if spillover==1 & EndDateUS<mdy(04, 04, 1841)
{txt}(1 real change made)

{com}. replace Pres2 = "Van_Buren" if spillover==1 & EndDateUS<mdy(03, 04, 1841)
{txt}(1 real change made)

{com}. replace Pres2 = "Jackson" if spillover==1 & EndDateUS<mdy(03, 04, 1837)
{txt}(0 real changes made)

{com}. replace Pres2 = "Quincy_Adams" if spillover==1 & EndDateUS<mdy(03, 04, 1829)
{txt}(0 real changes made)

{com}. replace Pres2 = "Monroe"  if spillover==1 & EndDateUS<mdy(03, 04, 1825)
{txt}(0 real changes made)

{com}. replace Pres2 = "Madison" if spillover==1 & EndDateUS<mdy(03, 04, 1817)
{txt}(0 real changes made)

{com}. 
. ** Merge with US presidents data using variable `varname'

. 
. gen varname=Pres1   

. sort varname

. 
. ** see presidentnames.xlsx for code for next section

. replace varname="madison" if varname=="Madison"
{txt}(1 real change made)

{com}. replace varname="monroe" if varname=="Monroe"
{txt}(6 real changes made)

{com}. replace varname="adams2" if varname=="AdamsJQ"
{txt}(1 real change made)

{com}. replace varname="jackson" if varname=="Jackson"
{txt}(4 real changes made)

{com}. replace varname="van_buren" if varname=="Van_Buren"
{txt}(4 real changes made)

{com}. replace varname="harrison1" if varname=="HarrisonWH"
{txt}(0 real changes made)

{com}. replace varname="tyler" if varname=="Tyler"
{txt}(2 real changes made)

{com}. replace varname="polk" if varname=="Polk"
{txt}(1 real change made)

{com}. replace varname="taylor" if varname=="Taylor"
{txt}(0 real changes made)

{com}. replace varname="fillmore" if varname=="Fillmore"
{txt}(3 real changes made)

{com}. replace varname="pierce" if varname=="Pierce"
{txt}(7 real changes made)

{com}. replace varname="buchanan" if varname=="Buchanan"
{txt}(6 real changes made)

{com}. replace varname="lincoln" if varname=="Lincoln"
{txt}(5 real changes made)

{com}. replace varname="johnson1" if varname=="JohnsonA"
{txt}(5 real changes made)

{com}. replace varname="grant" if varname=="Grant"
{txt}(8 real changes made)

{com}. replace varname="hayes" if varname=="Hayes"
{txt}(3 real changes made)

{com}. replace varname="garfield" if varname=="Garfield"
{txt}(0 real changes made)

{com}. replace varname="arthur" if varname=="Arthur"
{txt}(2 real changes made)

{com}. replace varname="cleveland" if varname=="Cleveland1"
{txt}(6 real changes made)

{com}. replace varname="harrison2" if varname=="HarrisonB"
{txt}(3 real changes made)

{com}. replace varname="cleveland2" if varname=="Cleveland2"
{txt}(5 real changes made)

{com}. replace varname="mckinley" if varname=="McKinley"
{txt}(3 real changes made)

{com}. replace varname="roosevelt1" if varname=="RooseveltT"
{txt}(10 real changes made)

{com}. replace varname="taft" if varname=="Taft"
{txt}(5 real changes made)

{com}. replace varname="wilson" if varname=="Wilson"
{txt}(19 real changes made)

{com}. replace varname="harding" if varname=="Harding"
{txt}(1 real change made)

{com}. replace varname="coolidge" if varname=="Coolidge"
{txt}(3 real changes made)

{com}. replace varname="hoover" if varname=="Hoover"
{txt}(2 real changes made)

{com}. replace varname="roosevelt2" if varname=="RooseveltFD"
{txt}(12 real changes made)

{com}. replace varname="truman" if varname=="Truman"
{txt}(10 real changes made)

{com}. replace varname="eisenhower" if varname=="Eisenhower"
{txt}(36 real changes made)

{com}. replace varname="kennedy" if varname=="Kennedy"
{txt}(16 real changes made)

{com}. replace varname="johnson2" if varname=="JohnsonLB"
{txt}(24 real changes made)

{com}. replace varname="nixon" if varname=="Nixon"
{txt}(16 real changes made)

{com}. replace varname="ford" if varname=="Ford"
{txt}(10 real changes made)

{com}. replace varname="carter" if varname=="Carter"
{txt}(14 real changes made)

{com}. replace varname="reagan" if varname=="Reagan"
{txt}(44 real changes made)

{com}. replace varname="bush1" if varname=="BushGHW"
{txt}(11 real changes made)

{com}. replace varname="clinton" if varname=="Clinton"
{txt}(32 real changes made)

{com}. replace varname="bush2" if varname=="BushGW"
{txt}(27 real changes made)

{com}. replace varname="obama" if varname=="Obama"
{txt}(5 real changes made)

{com}. 
. sort varname

. merge m:1 varname using "1-Original-Data/USPres2010-10-13.dta"                                         
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               6
{txt}{col 9}from master{col 30}{res}               0{txt}  (_merge==1)
{col 9}from using{col 30}{res}               6{txt}  (_merge==2)

{col 5}matched{col 30}{res}             372{txt}  (_merge==3)
{col 5}{hline 41}

{com}. tab _merge

                 {txt}_merge {c |}      Freq.     Percent        Cum.
{hline 24}{c +}{hline 35}
         using only (2) {c |}{res}          6        1.59        1.59
{txt}            matched (3) {c |}{res}        372       98.41      100.00
{txt}{hline 24}{c +}{hline 35}
                  Total {c |}{res}        378      100.00

{com}. order _merge

. ** Dropping Presidents not in the MID dataset

. drop if _merge==2
{txt}(6 observations deleted)

{com}. drop _merge

. sort StartDateUS dispnum3 dispnum4

. 
. 
. save "3-Analysis-Data/15-03-13-merging.dta", replace
{txt}(note: file 3-Analysis-Data/15-03-13-merging.dta not found)
file 3-Analysis-Data/15-03-13-merging.dta saved

{com}. 
. 
. clear

. use "3-Analysis-Data/15-03-13-merging.dta"

. 
. ** Indicator for Southern origin of Pres1 (under which MID started)

. gen South1 = 0

. replace South1 = 1 if inlist(Pres1, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH", "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{err}expression too long
{txt}{search r(130):r(130);}

{com}. replace South1 = . if Pres1=="" 
{txt}(0 real changes made)

{com}. 
. replace South1 = 1 if inlist(Pres1, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH")
{txt}(11 real changes made)

{com}. 
. replace South1 = 1 if inlist(Pres1, "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{txt}(124 real changes made)

{com}. 
. replace South1 = 1 if inlist(Pres1, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH", "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{err}expression too long
{txt}{search r(130):r(130);}

{com}. 
. clear

. use "3-Analysis-Data/15-03-13-merging.dta"

. 
. ** Indicator for Southern origin of Pres1 (under which MID started)

. gen South1 = 0

. replace South1 = 1 if inlist(Pres1, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH")
{txt}(11 real changes made)

{com}. replace South1 = 1 if inlist(Pres1, "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{txt}(124 real changes made)

{com}. replace South1 = . if Pres1=="" 
{txt}(0 real changes made)

{com}. 
. 
. ** Indicator for Southern origin of Pres2 (who inherited the MID)

. gen South2 = 0

. order Pres2 South2

. replace South2 = 1 if inlist(Pres2, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH")
{txt}(0 real changes made)

{com}. replace South2 = 1 if inlist(Pres2, "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{txt}(6 real changes made)

{com}. replace South2 = . if Pres2=="" 
{txt}(347 real changes made, 347 to missing)

{com}. 
. 
. 
. ** Start and end dates and length of presidents' terms

. gen TermStartDate = mdy(TermStartMonth, TermStartDay, TermStartYear)

. gen TermEndDate = mdy(TermEndMonth, TermEndDay, TermEndYear)  
{txt}(5 missing values generated)

{com}. 
. ** Assigning end of MID data as end of Term for Obama

. replace TermEndDate = mdy(12, 30, 2010) if Pres1=="Obama"
{txt}(5 real changes made)

{com}. replace TermStartDate = mdy(1, 1, 1816) if Pres1 == "Madison"
{txt}(1 real change made)

{com}. 
. format TermEndDate TermStartDate %td

. gen TermLength = TermEndDate - TermStartDate + 1 

. 
. ** Make Cleveland's term length be the sum of his two terms.

. tab TermLength if Pres1=="Cleveland1" | Pres1=="Cleveland2"

 {txt}TermLength {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       1462 {c |}{res}         11      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         11      100.00

{com}. replace TermLength = 2* 1462 if Pres1=="Cleveland1" | Pres1=="Cleveland2"
{txt}(11 real changes made)

{com}. 
. order TermStartDate TermEndDate

. 
. *** Code to create variable proprec, which measures the proportion of the 

. *** President's term that experienced a recession

. 
. ** daysrec is Days in Recession

. gen proprec = daysrec / TermLength

. 
. ** Days into Pres1's term that US involvement in the MID began/ended

. gen StrtDayInTrm1 = StartDateUS - TermStartDate

. rename TermStartDate TermStartDate1  
{res}
{com}. rename TermEndDate TermEndDate1               
{res}
{com}. 
. gen EndDayInTrm1 = EndDateUS - TermStartDate1

.                   
. gen DaysInTrm1 = LngthMIDUS

. replace DaysInTrm1 = TermEndDate1 - StartDateUS + 1 if Pres2!=""
{txt}(23 real changes made)

{com}. order StrtDayInTrm1 EndDayInTrm1

. 
. ** Indicator for the US being Originator of the dispute

. gen US_Init = orig

. 
. ** Indicator for US being the only nation on its side of the MID        

. gen US_alone = 0

. replace US_alone = 1 if sidea==1 & numa==1
{txt}(143 real changes made)

{com}. replace US_alone = 1 if sidea==0 & numb==1
{txt}(100 real changes made)

{com}. 
. ** Indicator for US's opponent being the only nation on its side

. gen opp_alone = 0

. replace opp_alone = 1 if sidea==1 & numb==1
{txt}(187 real changes made)

{com}. replace opp_alone = 1 if sidea==0 & numa==1
{txt}(151 real changes made)

{com}. 
. ** Indicator for both parties being the only nation on each's side

. gen BothAlone = US_alone*opp_alone

. 
. 
. ** Indicator for both parties being the only nation on each's side

. gen BothAlone = US_alone*opp_alone
{err}BothAlone already defined
{txt}{search r(110):r(110);}

{com}. 
. ** Index observations within each president, ordered by the date of US

. ** involvement, dispute number

. sort Pres1 StartDateUS dispnum3 dispnum4

. by Pres1: egen int PresOb = seq()

. sort StartDateUS dispnum3 dispnum4

. 
. ** Indicator for fishing disputes, from Cohen and Weeks

. gen FishDisp = 0

. replace FishDisp = 1 if dispnum3==1705 | dispnum3==3222 | dispnum3==2845 | dispnum3==3244 | dispnum3==1803 | dispnum3==1805 | dispnum3==350 | dispnum3==1158 | dispnum3==601 | dispnum3==602 | dispnum3==2952 | dispnum3==2954 | dispnum3==2953 | dispnum3==2958 | dispnum3==2222 | dispnum3==2968 | dispnum3==2967 | dispnum3==3972 | dispnum3==4183 | dispnum3==4174
{txt}(20 real changes made)

{com}. 
. ** Variable for number of opponents of US in MID

. gen nOpps = numb if sidea==1
{txt}(169 missing values generated)

{com}. replace nOpps = numa if sidea==0
{txt}(169 real changes made)

{com}. ** Correcting capitalization error

. replace Pres1 = "McKinley" if Pres1=="Mckinley"
{txt}(0 real changes made)

{com}. 
. *** Create placeholder observations for Presidents in whose terms no

. *** MIDs occurred

. set obs `=_N + 1'
{txt}obs was 372, now 373

{com}. replace Pres1 = "Washington" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 1 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(4, 30, 1789) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(3, 4, 1797) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 373, now 374

{com}. replace Pres1 = "AdamsJ" in l
{txt}(1 real change made)

{com}. replace South1 = 0 in l
{txt}(1 real change made)

{com}. replace Order = 2 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1797) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(3, 4, 1801) in l 
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 374, now 375

{com}. replace Pres1 = "Jefferson" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 3 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1801) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(3, 4, 1809) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l 
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 375, now 376

{com}. replace Pres1 = "HarrisonWH" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 9 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1841) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(4, 6, 1841) in l 
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. replace Party = "Whig" in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 376, now 377

{com}. replace Pres1 = "Taylor" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 12 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 5, 1849) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(7, 10, 1850) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. replace Party = "Whig" in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 377, now 378

{com}. replace Pres1 = "Garfield" in l
{txt}(1 real change made)

{com}. replace South1 = 0 in l
{txt}(1 real change made)

{com}. replace Order = 20 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1881) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(9, 20, 1881) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. replace Party = "Republican" in l
{txt}(1 real change made)

{com}. 
. 
. sort TermStartDate StartDateUS dispnum3 dispnum4

. 
. ** Create simpler version of party for first president

. gen Party1 = Party    
{txt}(3 missing values generated)

{com}. replace Party1 = "Democratic" if Party=="Democratic; National Union"
{txt}(5 real changes made)

{com}. replace Party1 = "Republican" if Party=="Republican; National Union"
{txt}(5 real changes made)

{com}. replace Party1 = "Whig" if Party=="Whig; None"
{txt}(2 real changes made)

{com}. replace Party1 = "Democratic-Republican" if  Party=="Democratic-Republican; National Republican"
{txt}(1 real change made)

{com}. encode Party1, generate (Party1Factor)

. 
. ** Labels for `outcome'

. label define outcome -1 "US Lose" 0 "Stalemate, Compromise, Released, Unclear, Join war, Missing" 1 "US Win"

. 
. label value outcome outcome

. 
. 
. 
. ** Indicator for whether the US was an Originator in the dispute

. gen Primary = 0

. replace Primary = 1 if orig==1
{txt}(316 real changes made)

{com}. 
. ** Create label for `Order' that includes missing presidents

. label define PresOrder 1 "Washington" 2 "AdamsJ" 3 "Jefferson" 4 "Madison" 5 "Monroe" 6 "AdamsJQ" 7 "Jackson" 8 "Van_Buren" 9 "HarrisonWH" 10 "Tyler" 11 "Polk" 12 "Taylor" 13 "Fillmore" 14 "Pierce" 15 "Buchanan" 16 "Lincoln" 17 "JohnsonA" 18 "Grant" 19 "Hayes" 20 "Garfield" 21 "Arthur" 22 "Cleveland" 23 "HarrisonB" 24 "Cleveland" 25 "McKinley" 26 "RooseveltT" 27 "Taft" 28 "Wilson" 29 "Harding" 30 "Coolidge" 31 "Hoover" 32 "RooseveltFD" 33 "Truman" 34 "Eisenhower" 35 "Kennedy" 36 "JohnsonLB" 37 "Nixon" 38 "Ford" 39 "Carter" 40 "Reagan" 41 "BushGHW" 42 "Clinton" 43 "BushGW" 44 "Obama"

. 
. gen Pres1Order = Order

. drop Order

. label values Pres1Order PresOrder 

. 
. ** Create cluster variable `Leader' that treats Cleveland's two terms 

. ** as one cluster

. generate Leader = Pres1Order

. replace Leader = 22 if Leader==24
{txt}(5 real changes made)

{com}. 
. ** Create label for `Leader' that includes missing presidents, but 

. ** Cleveland is only listed once.

. label define LeaderOrder 1 "Washington" 2 "AdamsJ" 3 "Jefferson" 4 "Madison" 5 "Monroe" 6 "AdamsJQ" 7 "Jackson" 8 "Van_Buren" 9 "HarrisonWH" 10 "Tyler" 11 "Polk" 12 "Taylor" 13 "Fillmore" 14 "Pierce" 15 "Buchanan" 16 "Lincoln" 17 "JohnsonA" 18 "Grant" 19 "Hayes" 20 "Garfield" 21 "Arthur" 22 "Cleveland" 23 "HarrisonB" 25 "McKinley" 26 "RooseveltT" 27 "Taft" 28 "Wilson" 29 "Harding" 30 "Coolidge" 31 "Hoover" 32 "RooseveltFD" 33 "Truman" 34 "Eisenhower" 35 "Kennedy" 36 "JohnsonLB" 37 "Nixon" 38 "Ford" 39 "Carter" 40 "Reagan" 41 "BushGHW" 42 "Clinton" 43 "BushGW" 44 "Obama"

. label values Leader LeaderOrder 

. 
. generate Leader2 = .
{txt}(378 missing values generated)

{com}. replace Leader2 = Leader[_n] + 1 if Pres2!=""
{txt}(25 real changes made)

{com}. label values Leader2 LeaderOrder

. 
. ** Previous and next presidents

. gen PresPrev = Pres1Order - 1

. label values PresPrev PresOrder

. gen PresNext = Pres1Order + 1

. label values PresNext PresOrder

. replace PresPrev = . if PresPrev==0
{txt}(1 real change made, 1 to missing)

{com}. replace PresNext = . if PresPrev==45
{txt}(0 real changes made)

{com}. 
. sort Pres1Order StartDateUS dispnum3 dispnum4

. 
. sort dispnum3 dispnum4

. by dispnum3 dispnum4: egen ObInDispute = seq()

. sort TermStartDate StartDateUS dispnum3 dispnum4

. 
. sort Leader StartDateUS dispnum3 dispnum4

. by Leader: egen int LeaderOb = seq()

. 
. browse if Leader==43

. clear

. **Code produced in 2015-03-13 by Allan Dafoe and Devin Caughey

. 
. clear

. use "3-Analysis-Data/15-03-13-merging.dta"

. 
. ** Indicator for Southern origin of Pres1 (under which MID started)

. gen South1 = 0

. replace South1 = 1 if inlist(Pres1, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH")
{txt}(11 real changes made)

{com}. replace South1 = 1 if inlist(Pres1, "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{txt}(124 real changes made)

{com}. replace South1 = . if Pres1=="" 
{txt}(0 real changes made)

{com}. 
. 
. ** Indicator for Southern origin of Pres2 (who inherited the MID)

. gen South2 = 0

. order Pres2 South2

. replace South2 = 1 if inlist(Pres2, "Washington", "Jefferson", "Madison", "Monroe", "Jackson", "HarrisonWH")
{txt}(0 real changes made)

{com}. replace South2 = 1 if inlist(Pres2, "Tyler", "Polk", "Taylor", "JohnsonA", "Wilson", "JohnsonLB", "Carter", "Clinton", "BushGW")
{txt}(6 real changes made)

{com}. replace South2 = . if Pres2=="" 
{txt}(347 real changes made, 347 to missing)

{com}. 
. 
. ** Start and end dates and length of presidents' terms

. gen TermStartDate = mdy(TermStartMonth, TermStartDay, TermStartYear)

. gen TermEndDate = mdy(TermEndMonth, TermEndDay, TermEndYear)  
{txt}(5 missing values generated)

{com}. 
. ** Assigning end of MID data as end of Term for Obama

. replace TermEndDate = mdy(12, 30, 2010) if Pres1=="Obama"
{txt}(5 real changes made)

{com}. replace TermStartDate = mdy(1, 1, 1816) if Pres1 == "Madison"
{txt}(1 real change made)

{com}. 
. format TermEndDate TermStartDate %td

. gen TermLength = TermEndDate - TermStartDate + 1 

. 
. ** Make Cleveland's term length be the sum of his two terms.

. tab TermLength if Pres1=="Cleveland1" | Pres1=="Cleveland2"

 {txt}TermLength {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       1462 {c |}{res}         11      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         11      100.00

{com}. replace TermLength = 2* 1462 if Pres1=="Cleveland1" | Pres1=="Cleveland2"
{txt}(11 real changes made)

{com}. 
. order TermStartDate TermEndDate

. 
. *** Code to create variable proprec, which measures the proportion of the 

. *** President's term that experienced a recession

. ** daysrec is Days in Recession

. gen proprec = daysrec / TermLength

. 
. ** Days into Pres1's term that US involvement in the MID began/ended

. gen StrtDayInTrm1 = StartDateUS - TermStartDate

. rename TermStartDate TermStartDate1  
{res}
{com}. rename TermEndDate TermEndDate1               
{res}
{com}. 
. gen EndDayInTrm1 = EndDateUS - TermStartDate1

.                   
. gen DaysInTrm1 = LngthMIDUS

. replace DaysInTrm1 = TermEndDate1 - StartDateUS + 1 if Pres2!=""
{txt}(23 real changes made)

{com}. order StrtDayInTrm1 EndDayInTrm1

. 
. ** Indicator for the US being Originator of the dispute

. gen US_Init = orig

. 
. ** Indicator for US being the only nation on its side of the MID        

. gen US_alone = 0

. replace US_alone = 1 if sidea==1 & numa==1
{txt}(143 real changes made)

{com}. replace US_alone = 1 if sidea==0 & numb==1
{txt}(100 real changes made)

{com}. 
. ** Indicator for US's opponent being the only nation on its side

. gen opp_alone = 0

. replace opp_alone = 1 if sidea==1 & numb==1
{txt}(187 real changes made)

{com}. replace opp_alone = 1 if sidea==0 & numa==1
{txt}(151 real changes made)

{com}. 
. ** Indicator for both parties being the only nation on each's side

. gen BothAlone = US_alone*opp_alone

. 
. ** Index observations within each president, ordered by the date of US

. ** involvement, dispute number

. sort Pres1 StartDateUS dispnum3 dispnum4

. by Pres1: egen int PresOb = seq()

. sort StartDateUS dispnum3 dispnum4

. 
. ** Indicator for fishing disputes, from Cohen and Weeks

. gen FishDisp = 0

. replace FishDisp = 1 if dispnum3==1705 | dispnum3==3222 | dispnum3==2845 | dispnum3==3244 | dispnum3==1803 | dispnum3==1805 | dispnum3==350 | dispnum3==1158 | dispnum3==601 | dispnum3==602 | dispnum3==2952 | dispnum3==2954 | dispnum3==2953 | dispnum3==2958 | dispnum3==2222 | dispnum3==2968 | dispnum3==2967 | dispnum3==3972 | dispnum3==4183 | dispnum3==4174
{txt}(20 real changes made)

{com}. 
. ** Variable for number of opponents of US in MID

. gen nOpps = numb if sidea==1
{txt}(169 missing values generated)

{com}. replace nOpps = numa if sidea==0
{txt}(169 real changes made)

{com}. 
. *** Create placeholder observations for Presidents in whose terms no

. *** MIDs occurred

. set obs `=_N + 1'
{txt}obs was 372, now 373

{com}. replace Pres1 = "Washington" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 1 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(4, 30, 1789) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(3, 4, 1797) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 373, now 374

{com}. replace Pres1 = "AdamsJ" in l
{txt}(1 real change made)

{com}. replace South1 = 0 in l
{txt}(1 real change made)

{com}. replace Order = 2 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1797) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(3, 4, 1801) in l 
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 374, now 375

{com}. replace Pres1 = "Jefferson" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 3 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1801) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(3, 4, 1809) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l 
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 375, now 376

{com}. replace Pres1 = "HarrisonWH" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 9 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1841) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(4, 6, 1841) in l 
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. replace Party = "Whig" in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 376, now 377

{com}. replace Pres1 = "Taylor" in l
{txt}(1 real change made)

{com}. replace South1 = 1 in l
{txt}(1 real change made)

{com}. replace Order = 12 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 5, 1849) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(7, 10, 1850) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. replace Party = "Whig" in l
{txt}(1 real change made)

{com}. set obs `=_N + 1'
{txt}obs was 377, now 378

{com}. replace Pres1 = "Garfield" in l
{txt}(1 real change made)

{com}. replace South1 = 0 in l
{txt}(1 real change made)

{com}. replace Order = 20 in l
{txt}(1 real change made)

{com}. replace TermStartDate = mdy(3, 4, 1881) in l
{txt}(1 real change made)

{com}. replace TermEndDate = mdy(9, 20, 1881) in l
{txt}(1 real change made)

{com}. replace TermLength = TermEndDate - TermStartDate + 1 in l
{txt}(1 real change made)

{com}. replace Party = "Republican" in l
{txt}(1 real change made)

{com}. 
. sort TermStartDate StartDateUS dispnum3 dispnum4

. 
. ** Create simpler version of party for first president

. gen Party1 = Party    
{txt}(3 missing values generated)

{com}. replace Party1 = "Democratic" if Party=="Democratic; National Union"
{txt}(5 real changes made)

{com}. replace Party1 = "Republican" if Party=="Republican; National Union"
{txt}(5 real changes made)

{com}. replace Party1 = "Whig" if Party=="Whig; None"
{txt}(2 real changes made)

{com}. replace Party1 = "Democratic-Republican" if  Party=="Democratic-Republican; National Republican"
{txt}(1 real change made)

{com}. encode Party1, generate (Party1Factor)

. 
. ** Labels for `outcome'

. label define outcome -1 "US Lose" 0 "Stalemate, Compromise, Released, Unclear, Join war, Missing" 1 "US Win"

. 
. label value outcome outcome

. 
. 
. ** Indicator for whether the US was an Originator in the dispute

. gen Primary = 0

. replace Primary = 1 if orig==1
{txt}(316 real changes made)

{com}. 
. ** Create label for `Order' that includes missing presidents

. label define PresOrder 1 "Washington" 2 "AdamsJ" 3 "Jefferson" 4 "Madison" 5 "Monroe" 6 "AdamsJQ" 7 "Jackson" 8 "Van_Buren" 9 "HarrisonWH" 10 "Tyler" 11 "Polk" 12 "Taylor" 13 "Fillmore" 14 "Pierce" 15 "Buchanan" 16 "Lincoln" 17 "JohnsonA" 18 "Grant" 19 "Hayes" 20 "Garfield" 21 "Arthur" 22 "Cleveland" 23 "HarrisonB" 24 "Cleveland" 25 "McKinley" 26 "RooseveltT" 27 "Taft" 28 "Wilson" 29 "Harding" 30 "Coolidge" 31 "Hoover" 32 "RooseveltFD" 33 "Truman" 34 "Eisenhower" 35 "Kennedy" 36 "JohnsonLB" 37 "Nixon" 38 "Ford" 39 "Carter" 40 "Reagan" 41 "BushGHW" 42 "Clinton" 43 "BushGW" 44 "Obama"

. 
. gen Pres1Order = Order

. drop Order

. label values Pres1Order PresOrder 

. 
. ** Create cluster variable `Leader' that treats Cleveland's two terms 

. ** as one cluster

. generate Leader = Pres1Order

. replace Leader = 22 if Leader==24
{txt}(5 real changes made)

{com}. 
. ** Create label for `Leader' that includes missing presidents, but 

. ** Cleveland is only listed once.

. label define LeaderOrder 1 "Washington" 2 "AdamsJ" 3 "Jefferson" 4 "Madison" 5 "Monroe" 6 "AdamsJQ" 7 "Jackson" 8 "Van_Buren" 9 "HarrisonWH" 10 "Tyler" 11 "Polk" 12 "Taylor" 13 "Fillmore" 14 "Pierce" 15 "Buchanan" 16 "Lincoln" 17 "JohnsonA" 18 "Grant" 19 "Hayes" 20 "Garfield" 21 "Arthur" 22 "Cleveland" 23 "HarrisonB" 25 "McKinley" 26 "RooseveltT" 27 "Taft" 28 "Wilson" 29 "Harding" 30 "Coolidge" 31 "Hoover" 32 "RooseveltFD" 33 "Truman" 34 "Eisenhower" 35 "Kennedy" 36 "JohnsonLB" 37 "Nixon" 38 "Ford" 39 "Carter" 40 "Reagan" 41 "BushGHW" 42 "Clinton" 43 "BushGW" 44 "Obama"

. 
. label values Leader LeaderOrder 

. 
. generate Leader2 = .
{txt}(378 missing values generated)

{com}. replace Leader2 = Leader[_n] + 1 if Pres2!=""
{txt}(25 real changes made)

{com}. label values Leader2 LeaderOrder

. 
. ** Note: the only difference between `Leader' and `Pres1Order' is that 

. ** the two non-consecutive administrations of Grover Cleveland are 

. ** listed under the same number (22) in `Leader' but as different 

. ** numbers (22 and 24) in `Pres1Order'. 

.  
. ** Previous and next presidents

. gen PresPrev = Pres1Order - 1

. label values PresPrev PresOrder

. gen PresNext = Pres1Order + 1

. label values PresNext PresOrder

. replace PresPrev = . if PresPrev==0
{txt}(1 real change made, 1 to missing)

{com}. replace PresNext = . if PresPrev==45
{txt}(0 real changes made)

{com}. 
. sort Pres1Order StartDateUS dispnum3 dispnum4

. 
. sort dispnum3 dispnum4

. by dispnum3 dispnum4: egen ObInDispute = seq()

. sort TermStartDate StartDateUS dispnum3 dispnum4

. 
. sort Leader StartDateUS dispnum3 dispnum4

. by Leader: egen int LeaderOb = seq()

. 
. ** Expressing Term Length in Years

. gen TermYrsAdj = TermLeng/365.25

. 
. 
. ** Number of MIDs of each Leader in each category

. by Leader, sort: egen nMIDs = total(FishDisp==0 | FishDisp==1)

. by Leader, sort: egen nMIDsNoF = total(FishDisp==0)

. by Leader, sort: egen nMIDsPrim = total(FishDisp==0 & Primary==1) 

. by Leader, sort: egen nMIDsAlone = total(FishDisp==0 & BothAlone==1)

. by Leader, sort: egen nMIDsAloneTarg = total(FishDisp==0 & BothAlone==1 & sidea==0)

. by Leader, sort: egen nMIDsAloneInit = total(FishDisp==0 & BothAlone==1 & sidea==1)

. 
. ** Each Leader's number of MIDs per year

. gen nMIDsPerYr = nMIDs/TermYrsAdj

. gen nMIDsNoFPerYr = nMIDsNoF/TermYrsAdj

. gen nMIDsPrimPerYr = nMIDsPrim/TermYrsAdj

. gen nMIDsAlonePerYr = nMIDsAlone/TermYrsAdj

. gen nMIDsAloneTargPerYr = nMIDsAloneTarg/TermYrsAdj

. gen nMIDsAloneInitPerYr = nMIDsAloneInit/TermYrsAdj

. 
. ** Each leader's # of MIDs in each category in which the US used Force

. by Leader, sort: egen nForce = total(ForceUS==1)

. by Leader, sort: egen nForceNoF = total(ForceUS==1 & FishDisp==0)

. by Leader, sort: egen nForcePrim = total(ForceUS==1 & FishDisp==0 & Primary==1) 

. by Leader, sort: egen nForceAlone = total(ForceUS==1 & FishDisp==0 & BothAlone==1)

. 
. ** Each leader's uses of force per year in each category

. gen nForcePerYr = nForce/TermYrsAdj

. gen nForceNoFPerYr = nForceNoF/TermYrsAdj

. gen nForcePrimPerYr = nForcePrim/TermYrsAdj

. gen nForceAlonePerYr = nForceAlone/TermYrsAdj 

. 
. ** Each leader's uses of force per MID in each category

. gen nForcePerMID = nForce/nMIDs
{txt}(6 missing values generated)

{com}. gen nForcePerMIDNoF = nForceNoF/nMIDsNoF
{txt}(6 missing values generated)

{com}. gen nForcePerMIDPrim = nForcePrim/nMIDsPrim
{txt}(6 missing values generated)

{com}. gen nForcePerMIDAlone = nForceAlone/nMIDsAlone
{txt}(9 missing values generated)

{com}. 
. 
. ** Time variables

. gen TermStartDateSq = TermStartDate1^2

. gen TermStartDateCu = TermStartDate1^3

. gen Era = 1

. replace Era = 2 if Leader>=25 & Leader<33
{txt}(55 real changes made)

{com}. replace Era = 3 if Leader>=33
{txt}(245 real changes made)

{com}. label define Era 1 "pre-1897" 2 "1897-1945" 3 "post-1945"

. label values Era Era

. 
. ** Merge country-year data (this is a subset of Gelpi and 

. ** Feaver's data with one observation per year)

. ** Merging on MID Start Year

. gen year = styear
{txt}(6 missing values generated)

{com}. sort year

. merge m:1 year using "1-Original-Data/bigstickcountry-year.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}             123
{txt}{col 9}from master{col 30}{res}              71{txt}  (_merge==1)
{col 9}from using{col 30}{res}              52{txt}  (_merge==2)

{col 5}matched{col 30}{res}             307{txt}  (_merge==3)
{col 5}{hline 41}

{com}. tab _merge

                 {txt}_merge {c |}      Freq.     Percent        Cum.
{hline 24}{c +}{hline 35}
        master only (1) {c |}{res}         71       16.51       16.51
{txt}         using only (2) {c |}{res}         52       12.09       28.60
{txt}            matched (3) {c |}{res}        307       71.40      100.00
{txt}{hline 24}{c +}{hline 35}
                  Total {c |}{res}        430      100.00

{com}. sum year if _merge==1

{txt}    Variable {c |}       Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 56}
{space 8}year {c |}{res}        65    2000.908    5.011621       1993       2010

{com}. ** G&F's data doesn't go beyond 1992.

. 
. ** _merge==2 are country-years when there was not a MID.

. drop if _merge==2
{txt}(52 observations deleted)

{com}. drop _merge

. 
. 
. sort Pres1Order StartDateUS

. 
. replace ObInDispute = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nMIDs = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nMIDsNoF = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nMIDsPrim = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nMIDsAlone = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nForce = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nForceNoF = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nForcePrim = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. replace nForceAlone = . if Leader<=3 | Leader>=44
{txt}(8 real changes made, 8 to missing)

{com}. 
. 
. *** Alternative assignment of MIDs to Leader2

. generate alt = .
{txt}(378 missing values generated)

{com}. replace alt = 0 if dispnum3!=.
{txt}(372 real changes made)

{com}. ** Mexican-American War (Tyler and Polk)

. replace alt = 1 if dispnum3==1552
{txt}(1 real change made)

{com}. ** 1958-61 dipute with North Korea (Eisenhower and Kennedy)

. replace alt = 1 if dispnum3==2187
{txt}(1 real change made)

{com}. ** Bay of Pigs Invasion (Eisenhower and Kennedy)

. replace alt = 1 if dispnum3==40
{txt}(0 real changes made)

{com}. ** 1963-64 dispute with North Korea (Kennedy and JohnsonLB)

. replace alt = 1 if dispnum3==2189
{txt}(1 real change made)

{com}. ** Cambodian Campaign (JohnsonLB and Nixon)

. replace alt = 1 if dispnum3==1806
{txt}(1 real change made)

{com}. ** Invasion of Panama (Reagan and BushGHW)                         

. replace alt = 1 if dispnum3==3901
{txt}(1 real change made)

{com}. ** Yugoslav wars (BushGHW and Clinton)

. replace alt = 1 if dispnum3==3551
{txt}(1 real change made)

{com}. generate Leader_alt = Leader

. replace Leader_alt = Leader2 if alt==1
{txt}(6 real changes made)

{com}. label values Leader_alt LeaderOrder

. 
. 
. ** Number of MIDs of each Leader_alt in each category

. by Leader_alt, sort: egen nMIDs_alt = total(FishDisp==0 | FishDisp==1)

. by Leader_alt, sort: egen nMIDsNoF_alt = total(FishDisp==0)

. by Leader_alt, sort: egen nMIDsPrim_alt = total(FishDisp==0 & Primary==1) 

. by Leader_alt, sort: egen nMIDsAlone_alt = total(FishDisp==0 & BothAlone==1)

. 
. 
. ** Each Leader_alt's number of MIDs per year

. gen nMIDsPerYr_alt = nMIDs_alt/TermYrsAdj

. gen nMIDsNoFPerYr_alt = nMIDsNoF_alt/TermYrsAdj

. gen nMIDsPrimPerYr_alt = nMIDsPrim_alt/TermYrsAdj

. gen nMIDsAlonePerYr_alt = nMIDsAlone_alt/TermYrsAdj

. 
. ** Each leader's # of MIDs in each category in which the US used Force

. by Leader_alt, sort: egen nForce_alt = total(ForceUS==1)

. by Leader_alt, sort: egen nForceNoF_alt = total(ForceUS==1 & FishDisp==0)

. by Leader_alt, sort: egen nForcePrim_alt = total(ForceUS==1 & FishDisp==0 & Primary==1) 

. by Leader_alt, sort: egen nForceAlone_alt = total(ForceUS==1 & FishDisp==0 & BothAlone==1)

. 
. 
. ** Each leader's uses of force per year in each category

. gen nForcePerYr_alt = nForce_alt/TermYrsAdj

. gen nForceNoFPerYr_alt = nForceNoF_alt/TermYrsAdj

. gen nForcePrimPerYr_alt = nForcePrim_alt/TermYrsAdj

. gen nForceAlonePerYr_alt = nForceAlone_alt/TermYrsAdj 

. 
. ** Each leader's uses of force per MID in each category

. gen nForcePerMID_alt = nForce_alt/nMIDs
{txt}(11 missing values generated)

{com}. gen nForcePerMIDNoF_alt = nForceNoF_alt/nMIDsNoF
{txt}(11 missing values generated)

{com}. gen nForcePerMIDPrim_alt = nForcePrim_alt/nMIDsPrim
{txt}(11 missing values generated)

{com}. gen nForcePerMIDAlone_alt = nForceAlone_alt/nMIDsAlone
{txt}(14 missing values generated)

{com}. 
. order Leader Leader_alt StartDateUS EndDateUS South1 outcome fatality ForceUS LngthMIDUS dispnum3 dispnum4 Party MiltExp MiltOcc TermLength proprec Era lnprevdead pctvetmi

. 
. sort Pres1Order StartDateUS

. 
. do "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/2-150317-Data-Merge/2-150317-data-merge0.do"
{txt}
{com}. **Code produced in 2015-03-13 by Allan Dafoe and Devin Caughey
. 
. clear 
{txt}
{com}. 
. ** Set base working directory
. cd "/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/"
{res}/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final
{txt}
{com}. 
. log using "2-150317-data-merge-log.smcl", replace
{err}log file already open
{txt}{search r(604):r(604);}

end of do-file

{search r(604):r(604);}

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/Allan/Dropbox/1Papers/1Reputation/Honor-Culture-War/2012-05/Replication-Final/1-Original-Data/2-150317-data-merge-log.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}17 Mar 2015, 14:35:07
{txt}{.-}
{smcl}
{txt}{sf}{ul off}